fix some bugs in parsing
This commit is contained in:
parent
fd54e5221a
commit
3dfb889728
5 changed files with 13 additions and 23 deletions
|
@ -32,14 +32,10 @@ class PyTeXConfig(Config):
|
|||
YAML_CLEAN_OLD_FILES: self._clean_old_files,
|
||||
YAML_ALLOW_DIRTY_BUILD: self._allow_dirty,
|
||||
YAML_FORCE_MODE: self._force_mode,
|
||||
YAML_DIRS: self._build_dir_specification.to_json()
|
||||
YAML_DIRS: self.build_dir_specification.to_json()
|
||||
},
|
||||
YAML_DEFAULT: {
|
||||
self._default_formatting_config.to_json()
|
||||
},
|
||||
YAML_CONFIGS: {
|
||||
self._configs
|
||||
}
|
||||
YAML_DEFAULT: self.default_formatting_config.to_json(),
|
||||
YAML_CONFIGS: self._configs
|
||||
}
|
||||
|
||||
def set_from_json(self, content: Dict):
|
||||
|
|
|
@ -15,7 +15,7 @@ YAML_HEADER = 'header'
|
|||
YAML_INCLUDE_EXTRA_HEADER = 'include'
|
||||
YAML_INCLUDE_BUILD_TIME = 'time'
|
||||
YAML_INCLUDE_VERSION = 'version'
|
||||
YAML_INCLUDE_INFO_TEXT = 'text'
|
||||
YAML_INCLUDE_INFO_TEXT = 'info'
|
||||
YAML_INCLUDE_TIME = 'time'
|
||||
YAML_AUTHOR = 'author'
|
||||
YAML_VERSION = 'version'
|
||||
|
|
|
@ -67,6 +67,7 @@ class FormattingConfig(Config):
|
|||
self._tex_flavour = info[YAML_TEX_FLAVOUR]
|
||||
self._tex_type = info[YAML_TEX_TYPE]
|
||||
self._description = info[YAML_DESCRIPTION]
|
||||
self._version = info[YAML_VERSION]
|
||||
|
||||
header = content[YAML_HEADER]
|
||||
extra = header[YAML_EXTRA]
|
||||
|
|
|
@ -4,14 +4,14 @@ from ..logger import logger
|
|||
|
||||
|
||||
class GenericText:
|
||||
def __init__(self, content: Optional[Union[List[str], Path]] = None):
|
||||
def __init__(self, content: Optional[Union[List[str], Path, str]] = None):
|
||||
if isinstance(content, list):
|
||||
self._content: Optional[List[str]] = content
|
||||
self._path = None
|
||||
self._initialized = True
|
||||
elif isinstance(content, Path):
|
||||
elif isinstance(content, Path) or isinstance(content, str):
|
||||
self._content: Optional[List[str]] = None
|
||||
self._path = content
|
||||
self._path = Path(content)
|
||||
self._initialized = True
|
||||
else:
|
||||
self._content = None
|
||||
|
|
17
main.py
17
main.py
|
@ -1,9 +1,11 @@
|
|||
from pathlib import Path
|
||||
from PyTeX.build.build import PyTeXBuilder
|
||||
from PyTeX.build.build import PyTeXBuilder, BuildDirConfig
|
||||
from PyTeX.build.build.build_dir_spec import BuildDirConfig
|
||||
from PyTeX.build.enums import *
|
||||
from PyTeX.build.paths import RelativePath
|
||||
|
||||
from PyTeX.build.build.pytex_config import PyTeXConfig
|
||||
|
||||
from PyTeX.format.formatting_config import FormattingConfig
|
||||
from PyTeX.format.generic_text import GenericText
|
||||
|
||||
|
@ -53,20 +55,11 @@ config: FormattingConfig = FormattingConfig()
|
|||
|
||||
dump = config.to_json()
|
||||
|
||||
config.naming_scheme = 'prepend-author'
|
||||
|
||||
conf_path = Path('/home/maximilian/git/LatexPackages/.pytexrc')
|
||||
|
||||
config.extra_header = GenericText(Path('header.txt'))
|
||||
config.extra_header = GenericText(['hello', 'world'])
|
||||
config.dump_as_yaml(Path('test.yaml'))
|
||||
pytex_config = PyTeXConfig.from_yaml(conf_path)
|
||||
|
||||
json = config.to_json()
|
||||
|
||||
config2 = FormattingConfig()
|
||||
config2.set_from_json(json)
|
||||
|
||||
|
||||
config3 = FormattingConfig.from_yaml(Path('test.yaml'))
|
||||
pass
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue