• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rero / sonar / 17425918180

03 Sep 2025 07:11AM UTC coverage: 95.796% (-0.6%) from 96.378%
17425918180

push

github

PascalRepond
translations: extract messages

Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>

7816 of 8159 relevant lines covered (95.8%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.24
/sonar/snl/ftp/__init__.py
1
# Swiss Open Access Repository
2
# Copyright (C) 2023 RERO
3
#
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU Affero General Public License as published by
6
# the Free Software Foundation, version 3 of the License.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
12
#
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15

16
"""SNL FTP repository."""
17

18
from pysftp import Connection
1✔
19

20

21
class SNLRepository:
1✔
22
    """SNL FTP repository."""
23

24
    def __init__(self, host, user, password, directory):
1✔
25
        """Init class.
26

27
        :param host: FTP host.
28
        :param user: FTP user.
29
        :param password: FTP password.
30
        :param directory: Directory where files are stored.
31
        """
32
        self.host = host
1✔
33
        self.user = user
1✔
34
        self.password = password
1✔
35
        self.directory = directory
1✔
36

37
    def connect(self):
1✔
38
        """Connect to FTP server and change directory."""
39
        self.client = Connection(
1✔
40
            self.host,
41
            username=self.user,
42
            password=self.password,
43
            default_path=self.directory,
44
        )
45

46
    def make_dir(self, pathname):
1✔
47
        """Make new directory via FTP connection."""
48
        self.client.mkdir(pathname)
1✔
49

50
    def cwd(self, pathname):
1✔
51
        """Move to directory via FTP connection."""
52
        self.client.cd(pathname)
×
53

54
    def upload_file(self, file_path, file_name):
1✔
55
        """Upload file to SNL server via FTP connection.
56

57
        :param filepath: local filepath of file to upload
58
        """
59
        self.client.put(file_path, file_name)
1✔
60

61
    def close(self):
1✔
62
        """Close FTP connection."""
63
        self.client.close()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc