Optimize get last package
This commit is contained in:
parent
5f30d588dc
commit
e10aa66da4
16
App.py
16
App.py
@ -24,32 +24,32 @@ api.add_resource(
|
||||
api.add_resource(
|
||||
BrowseRepoVersion,
|
||||
'/<string:repo_name>/<string:package_name>/<int:version_major>',
|
||||
# Retrieve data version <package_name> from default <repo_name>
|
||||
# Retrieve data version <package_name> from <repo_name>
|
||||
'/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>',
|
||||
# Retrieve data version <package_name> from default <repo_name>
|
||||
# Retrieve data version <package_name> from <repo_name>
|
||||
'/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>/<int:version_release>',
|
||||
# Retrieve data version <package_name> from default <repo_name>
|
||||
# Retrieve data version <package_name> from <repo_name>
|
||||
)
|
||||
|
||||
api.add_resource(
|
||||
InfoLastPackage,
|
||||
'/<string:repo_name>/<string:package_name>/last', # Download last version <package_name> from default <repo_name>
|
||||
'/<string:repo_name>/<string:package_name>/last', # Info for last version <package_name> from <repo_name>
|
||||
)
|
||||
|
||||
api.add_resource(
|
||||
DownloadLastPackage,
|
||||
'/download/<string:repo_name>/<string:package_name>/last',
|
||||
# Download last version <package_name> from default <repo_name>
|
||||
# Download last version <package_name> from <repo_name>
|
||||
)
|
||||
|
||||
api.add_resource(
|
||||
DownloadPackageVersion,
|
||||
'/download/<string:repo_name>/<string:package_name>/<int:version_major>',
|
||||
# Download version <package_name> from default <repo_name>
|
||||
# Download version <package_name> from <repo_name>
|
||||
'/download/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>',
|
||||
# Download version <package_name> from default <repo_name>
|
||||
# Download version <package_name> from <repo_name>
|
||||
'/download/<string:repo_name>/<string:package_name>/<int:version_major>/<int:version_minor>/<int:version_release>',
|
||||
# Download version <package_name> from default <repo_name>
|
||||
# Download version <package_name> from <repo_name>
|
||||
)
|
||||
|
||||
api.add_resource(
|
||||
|
@ -43,6 +43,7 @@ class PackageVersioning(FileSystemEventHandler):
|
||||
def __init__(self, repos_json_conf, prefix_url_download="/download"):
|
||||
self.__repos_public = {}
|
||||
self.__repos_private = {}
|
||||
self.__repos_last = {}
|
||||
self.__repos_json_conf = repos_json_conf
|
||||
self.__repos_obs = []
|
||||
self.__prefix_url_download = prefix_url_download
|
||||
@ -59,6 +60,8 @@ class PackageVersioning(FileSystemEventHandler):
|
||||
"directory_path": os.path.abspath(directory_path),
|
||||
"package_finder": PackageFinder(regex_package_name)
|
||||
}
|
||||
repo_last= {}
|
||||
list_package_name = []
|
||||
|
||||
for filename in repo_private['package_finder'].find_packages(directory_path):
|
||||
package_path = os.path.join(directory_path, filename)
|
||||
@ -92,6 +95,7 @@ class PackageVersioning(FileSystemEventHandler):
|
||||
|
||||
if package_name not in repo_public:
|
||||
repo_public[package_name] = {}
|
||||
list_package_name.append(package_name)
|
||||
else:
|
||||
if str(version) in repo_public[package_name]:
|
||||
raise Exception("Conflict name package {} version {} ! Version already exist !"
|
||||
@ -112,9 +116,9 @@ class PackageVersioning(FileSystemEventHandler):
|
||||
|
||||
self.__repos_public[repo_name] = repo_public
|
||||
self.__repos_private[repo_name] = repo_private
|
||||
print(self.__repos_public)
|
||||
print(self.__repos_private)
|
||||
|
||||
for p in list_package_name:
|
||||
repo_last[p] = self.__get_last_version_package(package_name, repo_name)
|
||||
self.__repos_last[repo_name] = repo_last
|
||||
|
||||
def get_all_packages(self, package_name=None, repo_name=None):
|
||||
repo_name, repo_public, _ = self.__get_repo(repo_name)
|
||||
@ -126,7 +130,7 @@ class PackageVersioning(FileSystemEventHandler):
|
||||
print(repo_public)
|
||||
raise PackageDoNotExist
|
||||
|
||||
def get_last_version_package(self, package_name, repo_name):
|
||||
def __get_last_version_package(self, package_name, repo_name):
|
||||
_, repo_public, _ = self.__get_repo(repo_name)
|
||||
|
||||
try:
|
||||
@ -142,6 +146,9 @@ class PackageVersioning(FileSystemEventHandler):
|
||||
|
||||
return package[str(last_version)]
|
||||
|
||||
def get_last_version_package(self, package_name, repo_name):
|
||||
return self.__repos_last[repo_name][package_name]
|
||||
|
||||
def get_path_package(self, filename, repo_name):
|
||||
_, _, repo_private = self.__get_repo(repo_name)
|
||||
if not repo_private[repo_name]['package_finder'].is_valid_filename(filename):
|
||||
|
Reference in New Issue
Block a user