Skip to content

Commit

Permalink
adding demo work + commenting unuseful file readings!
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazztok45 committed Nov 19, 2024
1 parent ab28a49 commit e8d8c15
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/zbmath_rest2oai/convertSoftware_from_json_toXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def convert_json_to_xml(json_file_path, xml_output_path):


# Example usage
JSON_FILE_PATH = '../../test/data/software/software_with_swhid.json'
XML_OUTPUT_PATH = '../../test/data/software/software_with_swhid.xml'
#JSON_FILE_PATH = '../../test/data/software/software_with_swhid.json'
#XML_OUTPUT_PATH = '../../test/data/software/software_with_swhid.xml'

convert_json_to_xml(JSON_FILE_PATH, XML_OUTPUT_PATH)
#convert_json_to_xml(JSON_FILE_PATH, XML_OUTPUT_PATH)
9 changes: 9 additions & 0 deletions src/zbmath_rest2oai/demo_archival.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from zbmath_rest2oai.staging_archival import Swhid
from zbmath_rest2oai.staging_archival import append_archived_url
import os
token = os.getenv('SWH_API_TOKEN')
url="https://github.com/appliedtopology/javaplex"
current_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.abspath(os.path.join(current_dir, "../../"))
archived_file_path = os.path.abspath(os.path.join(root_dir, "test/data/software/swh_swmath_archived.csv"))
print(Swhid(url,token).save_code_now())
10 changes: 5 additions & 5 deletions src/zbmath_rest2oai/restApi_software_Json.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def process_metadata(output_log_filename, csv_file_path, api_url, output_path=No
print(f"Failed to retrieve data. Status code: {response.status_code}")


csv_file_path = '../../test/data/software/swh_swmath_swhid_dir.csv' # Path to your CSV file
api_url = 'https://api.zbmath.org/v1/software/8779' # API URL, can be generalized for any software ID
output_path = '../../test/data/software/software_with_swhid.json'
output_log_filename = '../../test/data/software/logfile.txt'
process_metadata(output_log_filename, csv_file_path, api_url, output_path)
#csv_file_path = '../../test/data/software/swh_swmath_swhid_dir.csv' # Path to your CSV file
#api_url = 'https://api.zbmath.org/v1/software/8779' # API URL, can be generalized for any software ID
#output_path = '../../test/data/software/software_with_swhid.json'
#output_log_filename = '../../test/data/software/logfile.txt'
#process_metadata(output_log_filename, csv_file_path, api_url, output_path)
11 changes: 8 additions & 3 deletions src/zbmath_rest2oai/staging_deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
import tempfile
import os

env = os.environ.copy()
env['SWMATH_USER_DEPOSIT'] = os.getenv('SWMATH_USER_DEPOSIT')
env['SWMATH_PWD_DEPOSIT'] = os.getenv('SWMATH_PWD_DEPOSIT')
Expand All @@ -21,8 +22,12 @@
xml_output_path = '../test/data/software/software_with_swhid.xml' # Update with your desired output path
output_log_filename = '../test/data/software/logfile.txt'
xsl_filename = '../xslt/software/xslt-software-Codemeta.xslt'

for (i,swmath_id) in enumerate(pd.read_csv(csv_file_path)['swmathid']):
df= pd.read_csv(csv_file_path)
print(df.head().dtypes)
url="https://github.com/appliedtopology/javaplex"
df=df[df['cvs']==url]
print(df)
for (i,swmath_id) in enumerate(df['swmathid']):
if i == 10:
print("End of the deposit process")
break
Expand Down Expand Up @@ -56,4 +61,4 @@
"--url", "https://deposit.staging.swh.network/1",
"--metadata", temp_filename,
"--format", "json"
])
])

0 comments on commit e8d8c15

Please sign in to comment.