Skip to content

Commit

Permalink
fix: const.py should be a easily parsible file and work as raw data
Browse files Browse the repository at this point in the history
  • Loading branch information
LaoshuBaby committed Mar 24, 2024
1 parent 30f00b7 commit fb5930b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pre_build_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def main() -> None:
global_const_data = [
{x.split("=")[0]: x.split("=")[1]}
for x in open("src/yuheng/basic/global_const.py", "r")
for x in open("src/yuheng/basic/const.py", "r")
.read()
.replace(" ", "")
.replace('"', "")
Expand Down
5 changes: 2 additions & 3 deletions src/yuheng/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
from xml.etree import ElementTree as ET
from xml.etree.ElementTree import Element, ElementTree

from .basic.global_const import (
from .basic.const import (
YUHENG_CORE_NAME,
YUHENG_PATH,
YUHENG_START_ID,
YUHENG_VERSION,
get_yuheng_path,
)
from .basic.environment import get_yuheng_path
from .basic.log import logger
from .basic.model import BaseOsmModel
from .component.type_constraint import Bounds, Member
Expand Down
3 changes: 2 additions & 1 deletion src/yuheng/basic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .global_const import *
from .const import *
from .environment import *
from .log import *
from .model import *
10 changes: 10 additions & 0 deletions src/yuheng/basic/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
YUHENG_CORE_NAME = "Yuheng"
YUHENG_VERSION = "1.3.0"
YUHENG_START_ID = "-20210217"

API_LIMIT_MAX_CHANGESET_ELEMENTS = 10000
API_LIMIT_MAX_RELATION_MEMBERS = 32000
API_LIMIT_MAX_WAY_NODES = 2000
API_LIMIT_MAX_ELEMENT_TAGS = 5000
API_LIMIT_MAX_KEY_LENGTH = 255
API_LIMIT_MAX_VALUE_LENGTH = 255
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import os

YUHENG_CORE_NAME = "Yuheng"
YUHENG_VERSION = "1.3.0"
YUHENG_START_ID = "-20210217"

API_LIMIT_MAX_CHANGESET_ELEMENTS = 10000
API_LIMIT_MAX_RELATION_MEMBERS = 32000
API_LIMIT_MAX_WAY_NODES = 2000
API_LIMIT_MAX_ELEMENT_TAGS = 5000
API_LIMIT_MAX_KEY_LENGTH = 255
API_LIMIT_MAX_VALUE_LENGTH = 255

YUHENG_PATH = os.path.join(os.environ["USERPROFILE"], ".yuheng")


def get_ua() -> str:
return YUHENG_CORE_NAME + "/ " + YUHENG_VERSION
from .const import YUHENG_CORE_NAME, YUHENG_VERSION


def get_yuheng_path() -> str:
YUHENG_PATH = os.path.join(os.environ["USERPROFILE"], ".yuheng")

def init_yuheng_path() -> None:
YUHENG_FOLDER = ["cache", "db_profiles", "log"]
YUHENG_PROFILES = [
Expand Down Expand Up @@ -57,3 +44,7 @@ def init_yuheng_path() -> None:

init_yuheng_path()
return YUHENG_PATH


def get_ua() -> str:
return YUHENG_CORE_NAME + "/ " + YUHENG_VERSION
2 changes: 1 addition & 1 deletion src/yuheng/basic/log.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .global_const import get_yuheng_path
from .environment import get_yuheng_path
from hellologger import get_logger

log_config_local = {"foo": "bar"}
Expand Down
3 changes: 2 additions & 1 deletion src/yuheng/method/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""
from typing import Optional

from ..basic import YUHENG_CORE_NAME, YUHENG_VERSION, get_ua
from ..basic import YUHENG_CORE_NAME, YUHENG_VERSION
from ..basic.environment import get_ua


def get_endpoint_api(endpoint_name="osm", property="url") -> Optional[str]:
Expand Down

0 comments on commit fb5930b

Please sign in to comment.