Skip to content

Commit c3023c8

Browse files
dira271641dira271641
authored andcommitted
replaced with list comprehension pip version 2.0.3
1 parent 6e4397a commit c3023c8

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Useful functions to import and try
6767
from easy_fossy import easy_fossy as fossy
6868
6969
70-
To set the location of config.ini file and get the instance to access all the methos use below code
70+
To set the location of config.ini file and get the instance to access all the methods use below code
7171
7272
7373
use_fossy_to=fossy('location/config.ini','test')
@@ -166,9 +166,9 @@ From 1.0.9
166166
28. use_fossy_to.search_files_based_on(self, filename_wildcard: str, searchType: SearchType, uploadId: int, tag: str, filesizemin_bytes: int, filesizemax_bytes: int, license: str, copyright: str) -> List[SearchResults] | Info:
167167
--- give SearchType.Directory and filename_wildcard = 'draw%' (for draPaintIO.zip)
168168
169-
29 use_fossy_to.get_file_by_any_one_of_sha1_or_md5_or_sha256(self, sha1: str = '', md5: str = '', sha256: str = '') -> List[File]:
169+
29 use_fossy_to.get_file_by_any_one_of_sha1_or_md5_or_sha256(self, sha1: str = '', md5: str = '', sha256: str = '') -> str | List[File]:
170170
--- give only one hash of any of 3 format sha1 or sha256 or md5
171-
--- check for 'message' param of FILE class as it only appears if no file for hash is returned else it will not appear upload will appear
171+
--- returns list if even only data is there else it will return 'not found' string.
172172
173173
```
174174

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="easy_fossy",
8-
version="2.0.2",
8+
version="2.0.3",
99
author="dinesh_ravi",
1010
author_email="dineshr93@gmail.com",
1111
description="fossology API wrapper in python 3.10",

src/easy_fossy/__init__.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ def get_all_jobs(self) -> List[Job]:
174174

175175
match response.json():
176176
case [*args]:
177-
jobs = []
178-
for job in args:
179-
jobs.append(Job(**job))
177+
jobs = [Job(**job) for job in args]
180178
# for j in jobs:
181179
# print(jobs)
182180
return jobs
@@ -336,9 +334,7 @@ def get_all_folders(self) -> List[Folder]:
336334

337335
match response.json():
338336
case [*args]:
339-
folders = []
340-
for folder in args:
341-
folders.append(Folder(**folder))
337+
folders = [Folder(**folder) for folder in args]
342338
for f in folders:
343339
print(f)
344340
# print(folders)
@@ -533,9 +529,7 @@ def get_all_uploads_based_on(self, folder_id: int, is_recursive: bool, search_pa
533529

534530
match response.json():
535531
case [*args]:
536-
uploads = []
537-
for upload in args:
538-
uploads.append(Upload(**upload))
532+
uploads = [Upload(**upload) for upload in args]
539533
# for upload in uploads:
540534
# print(upload)
541535
return uploads
@@ -568,13 +562,12 @@ class Agent(Enum):
568562

569563
match response.json():
570564
case [*args]:
571-
UploadLicenses = []
572-
for uploadLicense in args:
573-
UploadLicenses.append(UploadLicense(**uploadLicense))
574-
for f in UploadLicenses:
565+
upload_icenses = [UploadLicense(
566+
**uploadLicense) for uploadLicense in args]
567+
for f in upload_icenses:
575568
print(f)
576569
# print(folders)
577-
return UploadLicenses
570+
return upload_icenses
578571
case {**info}:
579572
report_info = Info(**info)
580573
print(f'{report_info.message}')
@@ -1001,9 +994,7 @@ class Kind(Enum):
1001994

1002995
match response.json():
1003996
case [*args]:
1004-
licenses = []
1005-
for license in args:
1006-
licenses.append(License(**license))
997+
licenses = [License(**license) for license in args]
1007998
# for lic in licenses:
1008999
# print('======')
10091000
# print(lic)
@@ -1173,9 +1164,8 @@ def search_files_based_on(self, filename_wildcard: str, searchType: SearchType,
11731164

11741165
match response.json():
11751166
case [*args]:
1176-
search_results = []
1177-
for search_result in args:
1178-
search_results.append(SearchResults(**search_result))
1167+
search_results = [SearchResults(
1168+
**search_result) for search_result in args]
11791169
for s in search_results:
11801170
print(s)
11811171
# print(folders)
@@ -1187,8 +1177,8 @@ def search_files_based_on(self, filename_wildcard: str, searchType: SearchType,
11871177
case _:
11881178
print(response.text)
11891179

1190-
def get_file_by_any_one_of_sha1_or_md5_or_sha256(self, sha1: str = '', md5: str = '', sha256: str = '') -> List[File]:
1191-
"""def get_file_by_any_one_of_sha1_or_md5_or_sha256(self, sha1: str = '', md5: str = '', sha256: str = '') -> List[File]"""
1180+
def get_file_by_any_one_of_sha1_or_md5_or_sha256(self, sha1: str = '', md5: str = '', sha256: str = '') -> str | List[File]:
1181+
"""def get_file_by_any_one_of_sha1_or_md5_or_sha256(self, sha1: str = '', md5: str = '', sha256: str = '') -> str | List[File]"""
11921182
json_params = ''
11931183
if sha1 != '':
11941184
json_params = str(f'"sha1": {sha1}')
@@ -1222,10 +1212,11 @@ def get_file_by_any_one_of_sha1_or_md5_or_sha256(self, sha1: str = '', md5: str
12221212
"POST", self.url+str('filesearch'), json=payload, headers=headers)
12231213

12241214
match response.json():
1215+
case [{"message": error_message}]:
1216+
print(error_message)
1217+
return error_message
12251218
case [*args]:
1226-
files = []
1227-
for file in args:
1228-
files.append(File(**file))
1219+
files = [File(**file) for file in args]
12291220
for f in files:
12301221
print(f)
12311222
# print(folders)

0 commit comments

Comments
 (0)