Verified Commit a49f4c29 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

More pathlib, less os.path



Signed-off-by: Andrej Shadura's avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent 8ae2882d
......@@ -63,7 +63,7 @@ class DPut(object):
"""
current_path = os.getcwd()
project_path = os.path.join(self.working_dir, self.project_name)
project_path = self.working_dir / self.project_name
os.chdir(project_path)
osc.core.createPackageDir(self.package_name)
......@@ -73,7 +73,7 @@ class DPut(object):
project.commit()
os.chdir(current_path)
def _get_package_object(self):
def get_package_object(self):
"""
Returns a valid package object depending if the package already exists or
if it needs to be created
......@@ -81,35 +81,31 @@ class DPut(object):
# this one is needed because there's two ways of getting the package object
# first one fails if the folder already exists, the second one fail if it doesn't
path = os.path.join(self.working_dir, self.project_name, self.package_name)
if os.path.exists(path) and os.path.isdir(path):
path = self.working_dir / self.project_name / self.package_name
if path.is_dir():
os.chdir(path)
return osc.core.Package('.')
package = osc.core.Package(".")
return package
elif not os.path.exists(path):
elif not path.exists():
path.mkdir()
os.chdir(path)
package = osc.core.Package.init_package(conf.config['apiurl'],
project=self.project_name,
package=self.package_name,
dir=path,
dir='.',
meta=True)
package.update()
os.chdir(path)
return package
else:
print("Package folder couldn't be created")
raise Exception("Package folder couldn't be created")
def _get_remote_file_list(self, package):
def get_remote_file_list(self, package):
"""
Returns a list of files inside an specific package
"""
fileList = osc.core.meta_get_filelist(conf.config['apiurl'], self.project_name, self.package_name)
return fileList
return osc.core.meta_get_filelist(conf.config['apiurl'], self.project_name, self.package_name)
@cmdln.option('--maintained-in-git', action='store_true',
help='add MAINTAINED_IN_GIT.txt')
......@@ -143,10 +139,10 @@ def do_dput(self, subcmd, opts, proj_name, dsc_or_changes_file):
dput._create_package()
# it also changes the current_dir to the package dir
package = dput._get_package_object()
package = dput.get_package_object()
# defining file list, so we can decide which one to delete
remote_file_list = dput._get_remote_file_list(package)
remote_file_list = dput.get_remote_file_list(package)
local_file_list = [f["name"] for f in dsc.get("Files")] #local lambda list
# Remove old files, but only those that are part of the Debian package
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment