Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor content fetching #237

Merged
merged 43 commits into from
Mar 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
52ac17b
Extract method __get_dest_file_name
jan-cerny Mar 2, 2023
200eab4
Stop splitting URI
jan-cerny Mar 2, 2023
c298359
Stop passing object property as a method argument
jan-cerny Mar 2, 2023
7b0ae59
Change __get_dest_file_name to a property
jan-cerny Mar 2, 2023
f13a3b4
Set destination file name when URI is set
jan-cerny Mar 2, 2023
3a0ef3c
Remove unused parameter
jan-cerny Mar 2, 2023
af9c56e
Split method into 2 methods
jan-cerny Mar 2, 2023
2a030c9
Move fingerprint verification out from content analysis
jan-cerny Mar 2, 2023
c6038d4
Verify fingerprint of the downloaded file
jan-cerny Mar 2, 2023
b49dfff
Remove unused class member
jan-cerny Mar 2, 2023
e30695b
Pass the target URL as a parameter to fetch_content
jan-cerny Mar 2, 2023
89457dd
Move method closer to the caller method
jan-cerny Mar 2, 2023
b55b617
Move clear_all to PolicyData
jan-cerny Mar 3, 2023
e92b724
Remove unused code
jan-cerny Mar 3, 2023
ab6be82
Move method use_system_content
jan-cerny Mar 3, 2023
7e78b23
Move variable access
jan-cerny Mar 3, 2023
5d043d1
Move get_preffered_tailoring to ObtainedContent
jan-cerny Mar 3, 2023
a22296b
Move variable access
jan-cerny Mar 3, 2023
0012b07
Move method get_preffered_content
jan-cerny Mar 3, 2023
a04f4e8
Move use_downloaded_content to the PolicyData class
jan-cerny Mar 3, 2023
01b0237
Move variable access
jan-cerny Mar 3, 2023
990fe9a
Rename variable
jan-cerny Mar 3, 2023
46d028f
Don't access self._addon_data
jan-cerny Mar 3, 2023
8dec02d
Stop accessing self._addon_data
jan-cerny Mar 3, 2023
3ac39f8
Stop accessing self._addon_data
jan-cerny Mar 3, 2023
9cd6cf5
Remove PolicyData from ContentBringer
jan-cerny Mar 3, 2023
762be9b
Change get_content_type to static private method
jan-cerny Mar 3, 2023
f73871e
Change reduce_files to static method
jan-cerny Mar 3, 2023
a77dbf2
Change method to static
jan-cerny Mar 3, 2023
0fdaa65
Change method to private static method
jan-cerny Mar 3, 2023
f66b65b
Change method to static private method
jan-cerny Mar 3, 2023
680bc0c
Change method to private static method
jan-cerny Mar 3, 2023
617f466
Create ContentAnalyzer
jan-cerny Mar 3, 2023
292ac14
Move content analysis out from finish_content_fetch
jan-cerny Mar 3, 2023
5073ae4
Remove unused parameters
jan-cerny Mar 3, 2023
554ae38
Finish content fetching only if started
jan-cerny Mar 3, 2023
c086edd
Remove unused code
jan-cerny Mar 6, 2023
eeda474
Move the decision of verifying fingerprint
jan-cerny Mar 6, 2023
212ed3a
Move the failure callback parameter
jan-cerny Mar 6, 2023
94c97b4
Add missing doctext
jan-cerny Mar 6, 2023
b6c317e
Fix code style
jan-cerny Mar 6, 2023
3ca3959
Move methods out of PolicyData class
jan-cerny Mar 10, 2023
df9fd5c
Rename _content_uri to _valid_content_uri
jan-cerny Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't access self._addon_data
Don't access self._addon_data directly in filter_discovered_content
but instead pass them as parameter. This will reduce the dependency
on the PolicyData class (self._addon_data).
  • Loading branch information
jan-cerny committed Mar 3, 2023
commit 46d028f77e6eb46fb2abbc1a6efa1e95d737e9ee
12 changes: 7 additions & 5 deletions org_fedora_oscap/content_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,13 @@ def allow_one_expected_tailoring_or_no_tailoring(self, labelled_files, expected_
}
return labelled_files

def filter_discovered_content(self, labelled_files):
expected_path = common.get_preinst_content_path(self._addon_data)
def filter_discovered_content(self, labelled_files, expected_path, expected_tailoring, expected_cpe_path):
categories = (CONTENT_TYPES["DATASTREAM"], CONTENT_TYPES["XCCDF_CHECKLIST"])
if expected_path:
labelled_files = self.reduce_files(labelled_files, expected_path, categories)

expected_tailoring = common.get_preinst_tailoring_path(self._addon_data)
labelled_files = self.allow_one_expected_tailoring_or_no_tailoring(labelled_files, expected_tailoring)

expected_cpe_path = self._addon_data.cpe_path
categories = (CONTENT_TYPES["CPE_DICT"], )
if expected_cpe_path:
labelled_files = self.reduce_files(labelled_files, expected_cpe_path, categories)
Expand Down Expand Up @@ -249,7 +246,12 @@ def _analyze_fetched_content(self, wait_for, fingerprint, dest_filename):
structured_content.add_content_archive(dest_filename)

labelled_filenames = content_handling.identify_files(fpaths)
labelled_filenames = self.filter_discovered_content(labelled_filenames)
expected_path = common.get_preinst_content_path(self._addon_data)
expected_tailoring = common.get_preinst_tailoring_path(self._addon_data)
expected_cpe_path = self._addon_data.cpe_path
labelled_filenames = self.filter_discovered_content(
labelled_filenames, expected_path, expected_tailoring,
expected_cpe_path)

for fname, label in labelled_filenames.items():
structured_content.add_file(str(fname), label)
Expand Down