Skip to content

Commit

Permalink
Adds support for SB repos
Browse files Browse the repository at this point in the history
  • Loading branch information
richmahn committed Sep 1, 2023
1 parent b7e7230 commit e35f192
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
3 changes: 0 additions & 3 deletions TWL_TSV6_insert_into_HebGrk.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@ def handle_book(BBB:str, nn:str) -> Tuple[int,int]:
twl_C, twl_V, orig_TWL_words, occurrence, tw_category, tw_word = adjust_TWL_TSV_fields(next(TWL_source_line_generator))
if debugMode: print(f"Got TWL {BBB} {twl_C}:{twl_V}, '{orig_TWL_words}', {occurrence}, '{tw_category}/{tw_word}' with {len(outstanding_TWL_orig_words_list)} {outstanding_TWL_orig_words_list} and {len(origLang_words_in_this_USFM_verse)} {origLang_words_in_this_USFM_verse}")
while twl_C in twls_done and twl_V in twls_done[twl_C] and tw_category in twls_done[twl_C][twl_V] and tw_word in twls_done[twl_C][twl_V][tw_category] and orig_TWL_words in twls_done[twl_C][twl_V][tw_category][tw_word] and occurrence in twls_done[twl_C][twl_V][tw_category][tw_word]:
print("HERE!")
print(twls_done[twl_C][twl_V])
exit(1)
ocurrence += 1
if twl_C not in twls_done:
twls_done[twl_C] = {}
Expand Down
6 changes: 3 additions & 3 deletions converters/pdf/pdf_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,9 @@ def setup_resource(self, resource):
f' ...set up to use `{resource.repo_name}`: `{resource.ref}`')

def setup_resources(self):
if not self.manifest_dict:
self.log.error('No manifest.yaml file in repo')
return
# if not self.manifest_dict:
# self.log.error('No manifest.yaml file in repo')
# return
self.log.info('Setting up resources...')
# Setup Main Resource
repo_dir = None
Expand Down
45 changes: 43 additions & 2 deletions converters/pdf/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,55 @@ def last_commit_date(self):
@property
def manifest(self):
if not self._manifest:
if self.repo_dir:
if self.repo_dir and os.path.exists(os.path.join(self.repo_dir, 'manifest.yaml')):
self._manifest = load_yaml_object(os.path.join(self.repo_dir, 'manifest.yaml'))
else:
try:
response = AppSettings.repo_api.repo_get_contents(self.owner, self.repo_name, "manifest.yaml", ref=self.ref)
self._manifest = yaml.safe_load(base64.b64decode(response.content))
except ApiException as e:
print("Exception when calling RepositoryApi->repo_get_raw_file: %s\n" % e)
print("Exception when calling RepositoryApi->repo_get_contents: %s\n" % e)
if not self._manifest:
try:
repo = AppSettings.repo_api.repo_get(self.owner, self.repo_name)
self._manifest = {
"dublin_core": {
"contributor": [self.owner],
"creator": self.owner,
"format": repo.content_format,
"identifier": self.repo_name,
"issued": "",
"language": {
"direction": repo.language_direction,
"identifier": repo.language,
"title": repo.language_title,
},
"modified": "",
"publisher": self.owner,
"relation": [],
"rights": "CC BY-SA 4.0",
"source": [],
"subject": repo.subject,
"title": repo.title,
"type": "book",
"version": self.ref,
},
"checking": {
"checking_level": repo.checking_level
},
"projects": []
}
for ingredient in repo.ingredients:
self._manifest["projects"].append({
"categories": None,
"identifier": ingredient.identifier,
"path": ingredient.path,
"sort": ingredient.sort,
"title": ingredient.title,
"versification": ingredient.versification,
})
except ApiException as e:
print("Exception when calling RepositoryApi->repo_get: %s\n" % e)
return self._manifest

@property
Expand Down

0 comments on commit e35f192

Please sign in to comment.