mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 13:50:20 +08:00
Use __package__ instead of manual guessing
Thanks Nicola, how have I not found this! Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
This commit is contained in:
co-authored by
Nicola Soranzo
parent
400922a5a4
commit
cd409af528
@@ -43,7 +43,7 @@ def _from_dict(entry):
|
||||
return (name, ErrorCode(code, message))
|
||||
|
||||
|
||||
error_codes_json = resource_string(__name__.rsplit('.', 1)[0], 'error_codes.json')
|
||||
error_codes_json = resource_string(__package__, "error_codes.json")
|
||||
error_codes_by_name: Dict[str, ErrorCode] = {}
|
||||
|
||||
for entry in loads(error_codes_json):
|
||||
|
||||
@@ -85,7 +85,7 @@ RECOMMENDED_LICENSES = [
|
||||
"MPL-2.0",
|
||||
"PDDL-1.0",
|
||||
]
|
||||
SPDX_LICENSES_STRING = resource_string(__name__.rsplit('.', 1)[0], 'licenses.json')
|
||||
SPDX_LICENSES_STRING = resource_string(__package__, "licenses.json")
|
||||
SPDX_LICENSES = json.loads(SPDX_LICENSES_STRING)
|
||||
for license in SPDX_LICENSES["licenses"]:
|
||||
license["recommended"] = license["licenseId"] in RECOMMENDED_LICENSES
|
||||
|
||||
@@ -596,7 +596,7 @@ def to_pdf_raw(basic_markdown: str, css_paths: Optional[List[str]] = None) -> by
|
||||
output_file.write(as_html)
|
||||
output_file.close()
|
||||
html = weasyprint.HTML(filename=index)
|
||||
stylesheets = [weasyprint.CSS(string=resource_string(resource_string, 'markdown_export_base.css'))]
|
||||
stylesheets = [weasyprint.CSS(string=resource_string(__package__, "markdown_export_base.css"))]
|
||||
for css_path in css_paths:
|
||||
with open(css_path) as f:
|
||||
css_content = f.read()
|
||||
|
||||
@@ -5,6 +5,6 @@ from .components import Component
|
||||
|
||||
|
||||
def load_root_component() -> Component:
|
||||
new_data_yaml = resource_string(__name__.rsplit('.', 1)[0], 'navigation.yml')
|
||||
new_data_yaml = resource_string(__package__, "navigation.yml")
|
||||
navigation_raw = yaml.safe_load(new_data_yaml)
|
||||
return Component.from_dict("root", navigation_raw)
|
||||
|
||||
@@ -210,7 +210,7 @@ GALAXY_LIB_TOOLS_VERSIONED = {
|
||||
"winSplitter": packaging.version.parse("1.0.1"),
|
||||
}
|
||||
|
||||
BIOTOOLS_MAPPING_CONTENT = resource_string(__name__, 'biotools_mappings.tsv')
|
||||
BIOTOOLS_MAPPING_CONTENT = resource_string(__package__, "biotools_mappings.tsv")
|
||||
BIOTOOLS_MAPPING: Dict[str, str] = dict([cast(Tuple[str, str], tuple(x.split("\t"))) for x in BIOTOOLS_MAPPING_CONTENT.splitlines() if not x.startswith("#")])
|
||||
|
||||
REQUIRE_FULL_DIRECTORY = {
|
||||
|
||||
@@ -9,7 +9,7 @@ from galaxy.util.resources import resource_string
|
||||
|
||||
|
||||
def get_rules_specification():
|
||||
return yaml.safe_load(resource_string(__name__.rsplit('.', 1)[0], 'rules_dsl_spec.yml'))
|
||||
return yaml.safe_load(resource_string(__package__, "rules_dsl_spec.yml"))
|
||||
|
||||
|
||||
def _ensure_rule_contains_keys(rule, keys):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Galaxy webapps root package -- this is a namespace package."""
|
||||
|
||||
from pkgutil import extend_path
|
||||
|
||||
__path__ = extend_path(__path__, __name__) # type: ignore[has-type]
|
||||
|
||||
@@ -91,10 +91,10 @@ from .api import ApiTestInteractor
|
||||
CWL_TOOL_DIRECTORY = os.path.join(galaxy_root_path, "test", "functional", "tools", "cwl_tools")
|
||||
|
||||
# Simple workflow that takes an input and call cat wrapper on it.
|
||||
workflow_str = resource_string(__name__.rsplit('.', 1)[0], "data/test_workflow_1.ga")
|
||||
workflow_str = resource_string(__package__, "data/test_workflow_1.ga")
|
||||
# Simple workflow that takes an input and filters with random lines twice in a
|
||||
# row - first grabbing 8 lines at random and then 6.
|
||||
workflow_random_x2_str = resource_string(__name__.rsplit('.', 1)[0], "data/test_workflow_2.ga")
|
||||
workflow_random_x2_str = resource_string(__package__, "data/test_workflow_2.ga")
|
||||
|
||||
|
||||
DEFAULT_TIMEOUT = 60 # Secs to wait for state to turn ok
|
||||
@@ -1123,7 +1123,7 @@ class BaseWorkflowPopulator(BasePopulator):
|
||||
def load_workflow_from_resource(self, name: str, filename: Optional[str] = None) -> dict:
|
||||
if filename is None:
|
||||
filename = f"data/{name}.ga"
|
||||
content = resource_string(__name__.rsplit('.', 1)[0], filename)
|
||||
content = resource_string(__package__, filename)
|
||||
return self.load_workflow(name, content=content)
|
||||
|
||||
def simple_workflow(self, name: str, **create_kwds) -> str:
|
||||
|
||||
Reference in New Issue
Block a user