FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi-python-client/openapi_python_client/config.py at main · ramnes/openapi-python-client · GitHub
ramnes
openapi-python-client
Repository navigation
Code
Pull requests
10
(10)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
openapi-python-client
/
openapi_python_client
/
config.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (31 loc) · 1.36 KB
Breadcrumbs
openapi-python-client
/
openapi_python_client
/
config.py
Copy path
File metadata and controls
42 lines (31 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from
pathlib
import
Path
from
typing
import
Dict
,
Optional
import
yaml
from
pydantic
import
BaseModel
class
ClassOverride
(
BaseModel
):
class_name
:
str
module_name
:
str
class
Config
(
BaseModel
):
class_overrides
:
Optional
[
Dict
[
str
,
ClassOverride
]]
project_name_override
:
Optional
[
str
]
package_name_override
:
Optional
[
str
]
package_version_override
:
Optional
[
str
]
field_prefix
:
Optional
[
str
]
def
load_config
(
self
)
->
None
:
""" Sets globals based on Config """
from
openapi_python_client
import
Project
from
.
import
utils
from
.
parser
import
reference
if
self
.
class_overrides
is
not
None
:
for
class_name
,
class_data
in
self
.
class_overrides
.
items
():
reference
.
class_overrides
[
class_name
]
=
reference
.
Reference
(
**
dict
(
class_data
))
Project
.
project_name_override
=
self
.
project_name_override
Project
.
package_name_override
=
self
.
package_name_override
Project
.
package_version_override
=
self
.
package_version_override
if
self
.
field_prefix
is
not
None
:
utils
.
FIELD_PREFIX
=
self
.
field_prefix
@
staticmethod
def
load_from_path
(
path
:
Path
)
->
None
:
""" Creates a Config from provided JSON or YAML file and sets a bunch of globals from it """
config_data
=
yaml
.
safe_load
(
path
.
read_text
())
Config
(
**
config_data
).
load_config
()
Back
|
FazBrowse Home
|
New Git URL