From 598c0b81c328ab1efdbfe9127e2add02b7d647f9 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Mon, 26 Feb 2024 21:15:00 +0100 Subject: [PATCH 01/10] Updated package to V2.2.11 --- setup.py | 2 +- xbrl/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 59365f2..462813c 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ def read(filename): setup( name="py-xbrl", - version="2.2.10", + version="2.2.11", url="https://github.com/manusimidt/xbrl_parser", license='GNU General Public License v3 (GPLv3)', author="Manuel Schmidt", diff --git a/xbrl/__init__.py b/xbrl/__init__.py index 6bf3415..7f4b846 100644 --- a/xbrl/__init__.py +++ b/xbrl/__init__.py @@ -76,7 +76,7 @@ class ContextParseException(InstanceParseException): pass -__version__ = '2.2.10' +__version__ = '2.2.11' __author__ = 'Manuel Schmidt ' __all__ = [ XbrlParseException, From f5b2a245af82d176b35e63d998d48ddaa1987b89 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Sat, 6 Jul 2024 11:16:19 +0200 Subject: [PATCH 02/10] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..c136d39 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,14 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**XBRL document** +Please provide a link to the XBRL document(s) with which you have encountered the issue + +**Describe the bug** +A clear and concise description of what the bug is. From ff9f1d9d516950733e17015f99bb148782f8ad01 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Sat, 6 Jul 2024 11:20:27 +0200 Subject: [PATCH 03/10] Fixed #136 --- tests/test_local_taxonomy.py | 6 +++--- xbrl/taxonomy.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_local_taxonomy.py b/tests/test_local_taxonomy.py index 81bd203..1737361 100644 --- a/tests/test_local_taxonomy.py +++ b/tests/test_local_taxonomy.py @@ -18,10 +18,10 @@ def test_parse_taxonomy(self): cache_dir: str = './cache/' cache: HttpCache = HttpCache(cache_dir) print(f"Saving to {cache_dir}") - imported_schema_uris = set() + extension_schema_path: str = './tests/data/example.xsd' # extension_schema_path: str = './data/example.xsd' - tax: TaxonomySchema = parse_taxonomy(extension_schema_path, cache, imported_schema_uris = set()) + tax: TaxonomySchema = parse_taxonomy(extension_schema_path, cache) print(tax) srt_tax: TaxonomySchema = tax.get_taxonomy('http://fasb.org/srt/2020-01-31') self.assertTrue(srt_tax) @@ -32,4 +32,4 @@ def test_parse_taxonomy(self): if __name__ == '__main__': - unittest.main() + unittest.main() \ No newline at end of file diff --git a/xbrl/taxonomy.py b/xbrl/taxonomy.py index f9b078c..9e7bf92 100644 --- a/xbrl/taxonomy.py +++ b/xbrl/taxonomy.py @@ -281,6 +281,7 @@ "http://xbrl.sec.gov/dei/2021": "https://xbrl.sec.gov/dei/2021/dei-2021.xsd", "http://xbrl.sec.gov/dei/2022": "https://xbrl.sec.gov/dei/2022/dei-2022.xsd", "http://xbrl.sec.gov/dei/2023": "https://xbrl.sec.gov/dei/2023/dei-2023.xsd", + "http://xbrl.sec.gov/dei/2024": "https://xbrl.sec.gov/dei/2024/dei-2024.xsd", "http://xbrl.sec.gov/dei/2021q4": "https://xbrl.sec.gov/dei/2021q4/dei-2021q4.xsd", "http://xbrl.sec.gov/dei-def/2021": "https://xbrl.sec.gov/dei/2021/dei-2021_def.xsd", "http://xbrl.sec.gov/dei-entire/2021": "https://xbrl.sec.gov/dei/2021/dei-entire-2021.xsd", From bb0ef39ef9332fb3249bebf91ceb5e461fec27a8 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Sat, 6 Jul 2024 11:44:01 +0200 Subject: [PATCH 04/10] Fixed #138 --- xbrl/taxonomy.py | 1 + xbrl/transformations/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xbrl/taxonomy.py b/xbrl/taxonomy.py index 9e7bf92..cd128f1 100644 --- a/xbrl/taxonomy.py +++ b/xbrl/taxonomy.py @@ -168,6 +168,7 @@ "http://fasb.org/srt/2021-01-31": "http://xbrl.fasb.org/srt/2021/elts/srt-2021-01-31.xsd", "http://fasb.org/srt/2022": "https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd", "http://fasb.org/srt/2023": "https://xbrl.fasb.org/srt/2023/elts/srt-2023.xsd", + "http://fasb.org/srt/2024": "https://xbrl.fasb.org/srt/2024/elts/srt-2024.xsd", "http://fasb.org/srt-roles/2018-01-31": "http://xbrl.fasb.org/srt/2018/elts/srt-roles-2018-01-31.xsd", "http://fasb.org/srt-roles/2019-01-31": "http://xbrl.fasb.org/srt/2019/elts/srt-roles-2019-01-31.xsd", "http://fasb.org/srt-roles/2020-01-31": "http://xbrl.fasb.org/srt/2020/elts/srt-roles-2020-01-31.xsd", diff --git a/xbrl/transformations/__init__.py b/xbrl/transformations/__init__.py index 8c035b4..217ff51 100644 --- a/xbrl/transformations/__init__.py +++ b/xbrl/transformations/__init__.py @@ -311,7 +311,7 @@ def durWordSen(arg: str) -> str: def numWordSen(arg: str) -> str: - if arg == 'no' or arg == 'none': + if arg == 'no' or arg == 'none' or arg == 'nil': return '0' else: arg = arg.replace(' and ', ' ') From a7a144a9e34153881e450eadae11adafe45354b3 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Sat, 6 Jul 2024 12:22:56 +0200 Subject: [PATCH 05/10] Fixed issue with default args --- requirements.txt | 6 +++--- xbrl/taxonomy.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 352fe16..5212d6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -setuptools==65.5.1 -requests~=2.31.0 -urllib3~=1.26.11 +setuptools==70.2.0 +requests~=2.32.3 +urllib3~=2.2.2 diff --git a/xbrl/taxonomy.py b/xbrl/taxonomy.py index cd128f1..bcffd37 100644 --- a/xbrl/taxonomy.py +++ b/xbrl/taxonomy.py @@ -605,7 +605,7 @@ def parse_taxonomy_url(schema_url: str, cache: HttpCache, imported_schema_uris: return parse_taxonomy(schema_path, cache, imported_schema_uris, schema_url) -def parse_taxonomy(schema_path: str, cache: HttpCache, imported_schema_uris : set, schema_url: str or None = None) -> TaxonomySchema: +def parse_taxonomy(schema_path: str, cache: HttpCache, imported_schema_uris : set = set(), schema_url: str or None = None) -> TaxonomySchema: """ Parses a taxonomy schema file. From f4db5195a420514b554995449290b1ea1ebd7b60 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Sat, 6 Jul 2024 12:28:18 +0200 Subject: [PATCH 06/10] Updated package to V2.2.12 --- .gitignore | 1 + setup.py | 2 +- xbrl/__init__.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e9ce697..3d78185 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 .idea/ +.notes.md # Gradle and Maven with auto-import # When using Gradle or Maven with auto-import, you should exclude module files, diff --git a/setup.py b/setup.py index 462813c..38a43e4 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ def read(filename): setup( name="py-xbrl", - version="2.2.11", + version="2.2.12", url="https://github.com/manusimidt/xbrl_parser", license='GNU General Public License v3 (GPLv3)', author="Manuel Schmidt", diff --git a/xbrl/__init__.py b/xbrl/__init__.py index 7f4b846..130bcb7 100644 --- a/xbrl/__init__.py +++ b/xbrl/__init__.py @@ -76,7 +76,7 @@ class ContextParseException(InstanceParseException): pass -__version__ = '2.2.11' +__version__ = '2.2.12' __author__ = 'Manuel Schmidt ' __all__ = [ XbrlParseException, From 168a24bbcdaa36fa93eba0ef3a7e1e1687688ba5 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Sat, 6 Jul 2024 19:50:08 +0200 Subject: [PATCH 07/10] .github --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d9b1f4b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +# These are supported funding model platforms +buy_me_a_coffee: manusimidt From 1ac8d743d6af8dead0b4c30acb5093fcf471b5a8 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Tue, 9 Jul 2024 16:33:04 +0200 Subject: [PATCH 08/10] Fixed #138 --- xbrl/taxonomy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xbrl/taxonomy.py b/xbrl/taxonomy.py index bcffd37..8af967e 100644 --- a/xbrl/taxonomy.py +++ b/xbrl/taxonomy.py @@ -191,6 +191,7 @@ "http://fasb.org/us-gaap/2022-01-31": "https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd", "http://fasb.org/us-gaap/2022": "https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd", "http://fasb.org/us-gaap/2023": "https://xbrl.fasb.org/us-gaap/2023/elts/us-gaap-2023.xsd", + "http://fasb.org/us-gaap/2024": "https://xbrl.fasb.org/us-gaap/2024/elts/us-gaap-2024.xsd", "http://fasb.org/us-roles/2011-01-31": "http://xbrl.fasb.org/us-gaap/2011/elts/us-roles-2011-01-31.xsd", "http://fasb.org/us-roles/2012-01-31": "http://xbrl.fasb.org/us-gaap/2012/elts/us-roles-2012-01-31.xsd", "http://fasb.org/us-roles/2013-01-31": "http://xbrl.fasb.org/us-gaap/2013/elts/us-roles-2013-01-31.xsd", From 7c1ea7f9b3badfdbb11bb040bfedb63fb413b6e4 Mon Sep 17 00:00:00 2001 From: Paulo Vitor Magacho <139177232+pvmagacho-nde@users.noreply.github.com> Date: Tue, 30 Jul 2024 21:38:12 -0300 Subject: [PATCH 09/10] Update instance.py --- xbrl/instance.py | 70 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/xbrl/instance.py b/xbrl/instance.py index 81d01df..198c0b1 100644 --- a/xbrl/instance.py +++ b/xbrl/instance.py @@ -35,22 +35,69 @@ "xbrldi": "http://xbrl.org/2006/xbrldi" } +class AbstractMember: + def __init__(self, dimension: Concept) -> None: + self.dimension = dimension + + def __str__(self) -> str: + return "Dimension {}".format(self.dimension.name) + + def to_dict(self): + return { + 'dimension': self.dimension.to_dict(), + } + + def to_json(self): + return json.dumps(self.to_dict()) + -class ExplicitMember: +class TypedMember(AbstractMember): """ Representation of an explicit member in xbrl. XML Example: aapl:EuropeSegmentMember """ + def __init__(self, dimension: Concept, domain: List[str]) -> None: + super().__init__(dimension) + self.domain = domain + + def __str__(self) -> str: + return "{} on dimension {}".format(self.domain, self.dimension.name) + + def to_dict(self): + return { + 'dimension': self.dimension.to_dict(), + 'domain': self.domain + } + + def to_json(self): + return json.dumps(self.to_dict()) + + +class ExplicitMember(AbstractMember): + """ + Representation of an explicit member in xbrl. + XML Example: + aapl:EuropeSegmentMember + """ def __init__(self, dimension: Concept, member: Concept) -> None: - self.dimension = dimension + super().__init__(dimension) self.member = member def __str__(self) -> str: return "{} on dimension {}".format(self.member.name, self.dimension.name) + def to_dict(self): + return { + 'dimension': self.dimension.to_dict(), + 'member': self.member.to_dict() + } + + def to_json(self): + return json.dumps(self.to_dict()) + class AbstractContext(abc.ABC): """ @@ -64,7 +111,7 @@ class AbstractContext(abc.ABC): def __init__(self, xml_id: str, entity: str) -> None: self.xml_id: str = xml_id self.entity: str = entity - self.segments: List[ExplicitMember] = [] + self.segments: List[AbstractMember] = [] class InstantContext(AbstractContext): @@ -201,6 +248,7 @@ def json(self, **kwargs) -> dict: if 'dimensions' not in kwargs: kwargs['dimensions'] = {} kwargs['dimensions']['concept'] = self.concept.name kwargs['dimensions']['entity'] = self.context.entity + kwargs['dimensions']['contextId'] = self.context.xml_id kwargs['dimensions']['period'] = period for segment in self.context.segments: kwargs['dimensions'][segment.dimension.name] = segment.member.name @@ -657,6 +705,22 @@ def _parse_context_elements(context_elements: List[ET.Element], ns_map: dict, ta # add the explicit member to the context context.segments.append(ExplicitMember(dimension_concept, member_concept)) + for typed_member_element in segment.findall('xbrldi:typedMember', NAME_SPACES): + _update_ns_map(ns_map, typed_member_element.attrib['ns_map']) + dimension_prefix, dimension_concept_name = typed_member_element.attrib['dimension'].strip().split(':') + # get the taxonomy where the dimension attribute is defined + dimension_tax = taxonomy.get_taxonomy(ns_map[dimension_prefix]) + # check if the taxonomy was found + if dimension_tax is None: + # try to subsequently load the taxonomy + dimension_tax = _load_common_taxonomy(cache, ns_map[dimension_prefix], taxonomy) + dimension_concept: Concept = dimension_tax.concepts[dimension_tax.name_id_map[dimension_concept_name]] + domain: List[str] = [] + for child in typed_member_element: + domain.append(child.text.strip()) + + context.segments.append(TypedMember(dimension_concept, domain)) + context_dict[context_id] = context return context_dict From 6c04dbf3b851c513b5064a30de52e61addd5b774 Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Fri, 9 Aug 2024 20:10:13 +0200 Subject: [PATCH 10/10] Fixed small bug and docs for #143 --- xbrl/instance.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xbrl/instance.py b/xbrl/instance.py index 198c0b1..4f634de 100644 --- a/xbrl/instance.py +++ b/xbrl/instance.py @@ -35,7 +35,8 @@ "xbrldi": "http://xbrl.org/2006/xbrldi" } -class AbstractMember: + +class AbstractMember(abc.ABC): def __init__(self, dimension: Concept) -> None: self.dimension = dimension @@ -53,10 +54,12 @@ def to_json(self): class TypedMember(AbstractMember): """ - Representation of an explicit member in xbrl. + Representation of a typed member in xbrl. XML Example: - aapl:EuropeSegmentMember + + 2024-06-30 + """ def __init__(self, dimension: Concept, domain: List[str]) -> None: super().__init__(dimension) @@ -251,7 +254,8 @@ def json(self, **kwargs) -> dict: kwargs['dimensions']['contextId'] = self.context.xml_id kwargs['dimensions']['period'] = period for segment in self.context.segments: - kwargs['dimensions'][segment.dimension.name] = segment.member.name + if isinstance(segment, ExplicitMember): + kwargs['dimensions'][segment.dimension.name] = segment.member.name return kwargs