robotcode-core 2.9.0.dev180__py3-none-any.whl → 2.9.0.dev197__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- __version__ = "2.9.0-dev.180"
1
+ __version__ = "2.9.0-dev.197"
@@ -98,14 +98,19 @@ class DocumentsManager:
98
98
  def detect_language_id(self, path_or_uri: Union[str, "os.PathLike[Any]", Uri]) -> str:
99
99
  path = path_or_uri.to_path() if isinstance(path_or_uri, Uri) else Path(path_or_uri)
100
100
 
101
+ # the longest matching extension wins, so `.robot.md` beats `.md`
102
+ result = "unknown"
103
+ matched = 0
101
104
  for lang in self.languages:
102
- suffix = path.suffix
103
- if lang.extensions_ignore_case:
104
- suffix = suffix.lower()
105
- if suffix in lang.extensions:
106
- return lang.id
105
+ name = path.name.lower() if lang.extensions_ignore_case else path.name
106
+ for e in lang.extensions:
107
+ if len(e) > matched and len(name) > len(e) and name.endswith(e):
108
+ if lang.file_condition is not None and not lang.file_condition(path):
109
+ break
110
+ result = lang.id
111
+ matched = len(e)
107
112
 
108
- return "unknown"
113
+ return result
109
114
 
110
115
  @_logger.call
111
116
  def get_or_open_document(
@@ -1,4 +1,5 @@
1
1
  from dataclasses import dataclass
2
+ from pathlib import Path
2
3
  from typing import Any, Callable, List, Optional, TypeVar, Union
3
4
 
4
5
  from robotcode.core.text_document import TextDocument
@@ -38,3 +39,4 @@ class LanguageDefinition:
38
39
  extensions: List[str]
39
40
  extensions_ignore_case: bool = False
40
41
  aliases: Optional[List[str]] = None
42
+ file_condition: Optional[Callable[[Path], bool]] = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: robotcode-core
3
- Version: 2.9.0-dev.180
3
+ Version: 2.9.0-dev.197
4
4
  Summary: Some core classes for RobotCode
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -1,12 +1,12 @@
1
1
  robotcode/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- robotcode/core/__version__.py,sha256=39yWLbn8Xd-rhIKA3f_deOqSMNKc9u8vdFKv8xFpYNk,30
2
+ robotcode/core/__version__.py,sha256=TuhAPY5tWcB-O8yUsip8A5BqXPAkWXdXI0Yu5xcu0h8,30
3
3
  robotcode/core/async_tools.py,sha256=pU12trR8-w4oUoLXiV5uGQ9weGZS25b_DXCNwbbhcfI,12843
4
4
  robotcode/core/concurrent.py,sha256=-WPaxSsS7Vgzc3PyANtfBLHznZTPZ36T0ftRHzKO584,7058
5
- robotcode/core/documents_manager.py,sha256=zxrncZA_zxOAFgUWdItUixfLOFnTFla7-NrOTlblTMU,7613
5
+ robotcode/core/documents_manager.py,sha256=H3zNfQaXTYaXt5LDdkQDNeRNhDXc0SD9RLMRv1TN2jc,7937
6
6
  robotcode/core/event.py,sha256=AytdlzTCmTa_6i11nTxb50o9MAF1czRRadDwB6N0z9w,5522
7
7
  robotcode/core/filewatcher.py,sha256=Osxwq7xJNmhF3nGNP2NHk1HynTLdVuMlt4XYrDmF7aM,2300
8
8
  robotcode/core/ignore_spec.py,sha256=y_sFU-Z__xkpIW8MXcAWzl0vQQtKacZINaA0NkQ7Lw8,13334
9
- robotcode/core/language.py,sha256=1b6vhmwiYkEXtQ2_45iqXdAG5KD1sdenGyAZzML7gNY,1047
9
+ robotcode/core/language.py,sha256=Kg5zuQEE4atSD2lXk2Q2OwEBW5rJodo_MzikdfDTZKQ,1132
10
10
  robotcode/core/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
11
11
  robotcode/core/text_document.py,sha256=NqQQ4YHHHWkgqMBnLxxC5fQvxLeQ9hhEJkaEm7Wai_c,13712
12
12
  robotcode/core/types.py,sha256=xxDJsW3h_ygJTRtehalYAU9LsMHdbbBHCQapWA27i38,443
@@ -27,6 +27,6 @@ robotcode/core/utils/path.py,sha256=RDhRcLFXami154-zCe6GeYFyuL2Fuwrd8Teh-bPlIbA,
27
27
  robotcode/core/utils/process.py,sha256=nwTTmAyjcDybcO_fq0ZbZK_76ndBFO324z9cxni8TuU,679
28
28
  robotcode/core/utils/safe_eval.py,sha256=ES12mwdqNH4iHsP23sEBW6_bgGjS5DKFfgSfxP97-ok,1448
29
29
  robotcode/core/utils/version.py,sha256=uXcvqOFLbaSH5EWL6OwRDZjGteFzwaqt0Ll2Rf5h008,1373
30
- robotcode_core-2.9.0.dev180.dist-info/METADATA,sha256=5VIbyJo5zzC7MrkxEJO19uUdfjWOqSC-ZeP_tZ3jE-I,2764
31
- robotcode_core-2.9.0.dev180.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
32
- robotcode_core-2.9.0.dev180.dist-info/RECORD,,
30
+ robotcode_core-2.9.0.dev197.dist-info/METADATA,sha256=_3GYvpWHdwMpMUijwhasdCTenivQDOXfrnNGmmGrKeI,2764
31
+ robotcode_core-2.9.0.dev197.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
32
+ robotcode_core-2.9.0.dev197.dist-info/RECORD,,