Commit 32765da2 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Updated the readme for the example parser.

parent 7ba77ed9
Pipeline #91138 passed with stages
in 27 minutes and 23 seconds
***Note:** This is a general README file for NOMAD parsers, consult the README of specific parser projects for more detailed information!*
$preamble$
This is a NOMAD parser for [$codeLabel$]($codeUrl$). It will read $codeLabel$ input and
output files and provide all information in NOMAD's unified Metainfo based Archive format.
......@@ -64,7 +66,15 @@ python_dict = section_run.m_to_dict()
## Developing the parser
Also install NOMAD's pypi package:
Create a virtual environment to install the parser in development mode:
```
pip install virtualenv
virtualenv -p `which python3` .pyenv
source .pyenv/bin/activate
```
Install NOMAD's pypi package:
```
pip install nomad-lab
......
Subproject commit ca9596fcf15f938122d55ae12222dede9e3610a0
Subproject commit aff72472303ff1da53fe88388e6f7edc76f28535
......@@ -234,12 +234,12 @@ def update_parser_readmes(parser):
print('\tReplacing', key)
find = r'\$' + key + r'\$'
replace = mdata[key]
replace = mdata.get(key, '')
if key == 'parserSpecific':
if mdata[key] != '':
replace = r'---\n## Parser Specific\n' + replace
# print('\t', find, ' -> ', replace)
replace = r'## Parser Specific\n' + replace
body = re.sub(find, replace, body)
# Extra: to replace the codeName (there's no YAML key for this)
......@@ -265,56 +265,6 @@ def update_parser_readmes(parser):
local.truncate()
@dev.command(help='Updates parser`s metadata YAML')
def update_parsers_metadata():
import re
from glob import glob
print('\nPWD: ', os.getcwd())
print('WARNING: to be run from project`s root dir\n')
# Based on
# https://www.kite.com/python/answers/how-to-update-and-replace-text-in-a-file-in-python
# dictionary to change YAML keys to camelCase
new_keys = {
'code-label': 'codeLabel',
'code-label-style': 'codeLabelStyle',
'code-url': 'codeUrl',
'parser-dir-name': 'parserDirName',
'parser-git-url': 'parserGitUrl',
'parser-specific': 'parserSpecific',
'table-of-files': 'tableOfFiles'}
num = 0
parser_path = './dependencies/parsers/'
for ddir in sorted(glob(parser_path + '*/')):
num += 1
parser_dirname = ddir.split('/')[-2]
print('{} Working on {}' .format(num, parser_dirname))
local_mdata = ddir + 'metadata.yaml'
if os.path.isfile(local_mdata) is False:
print('\tWARNING: old readme file absent: {}'.format(local_mdata))
continue
# Replace key names in metadata.yaml
# we open it as plain text: YAML module is unnecesary
with open(local_mdata, 'r+') as local:
body = local.read()
for key in new_keys.keys():
# Add ':' to ensure complete sentence
find, replace = key + ':', new_keys[key] + ':'
# print('\t {:15} \t -> {} ' .format(find, replace))
body = re.sub(find, replace, body)
# save file
local.seek(0) # go to the top
local.write(body)
local.truncate()
@dev.command(help='Creates a Javascript source file containing the required unit conversion factors.')
@click.pass_context
def units(ctx):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment