maya-umbrella 0.10.0__py2.py3-none-any.whl → 0.11.0__py2.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.

Potentially problematic release.


This version of maya-umbrella might be problematic. Click here for more details.

@@ -0,0 +1 @@
1
+ six==1.16.0
maya_umbrella/cleaner.py CHANGED
@@ -5,13 +5,13 @@ import os
5
5
  import re
6
6
 
7
7
  # Import local modules
8
- from maya_umbrella.constants import FILE_VIRUS_SIGNATURES
9
8
  from maya_umbrella.filesystem import remove_virus_file_by_signature
10
9
  from maya_umbrella.filesystem import safe_remove_file
11
10
  from maya_umbrella.filesystem import safe_rmtree
12
11
  from maya_umbrella.i18n import Translator
13
12
  from maya_umbrella.maya_funs import check_reference_node_exists
14
13
  from maya_umbrella.maya_funs import cmds
14
+ from maya_umbrella.signatures import FILE_VIRUS_SIGNATURES
15
15
 
16
16
 
17
17
  class MayaVirusCleaner(object):
@@ -3,20 +3,3 @@ PACKAGE_NAME = "maya_umbrella"
3
3
  LOG_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
4
4
 
5
5
  LOG_MAX_BYTES = 1024 * 1024 * 5
6
-
7
- FILE_VIRUS_SIGNATURES = [
8
- "import vaccine",
9
- "cmds.evalDeferred.*leukocyte.+",
10
- # https://regex101.com/r/0MNzF7/1
11
- "python(.*);.+exec.+(pyCode).+;",
12
- ]
13
-
14
- JOB_SCRIPTS_VIRUS_SIGNATURES = [
15
- "petri_dish_path.+cmds.internalVar.+",
16
- "userSetup",
17
- "fuckVirus",
18
- # https://regex101.com/r/0MNzF7/1
19
- "python(.*);.+exec.+(pyCode).+;",
20
- # https://regex101.com/r/2D14UA/1
21
- r"^\['.+']",
22
- ]
@@ -1,5 +1,4 @@
1
1
  # Import built-in modules
2
- import codecs
3
2
  from contextlib import contextmanager
4
3
  import glob
5
4
  import importlib
@@ -10,16 +9,12 @@ import random
10
9
  import re
11
10
  import shutil
12
11
  import string
13
- import sys
14
12
  import tempfile
15
13
 
16
14
  # Import local modules
17
- from maya_umbrella.constants import FILE_VIRUS_SIGNATURES
15
+ from maya_umbrella._vendor import six
18
16
  from maya_umbrella.constants import PACKAGE_NAME
19
-
20
-
21
- PY2 = sys.version_info[0] == 2
22
- PY3 = sys.version_info[0] == 3
17
+ from maya_umbrella.signatures import FILE_VIRUS_SIGNATURES
23
18
 
24
19
 
25
20
  def this_root():
@@ -43,37 +38,24 @@ def safe_rmtree(path):
43
38
  pass
44
39
 
45
40
 
46
- def _codes_open(path, encoding="utf-8"):
47
- """Open and read the content of a file using the specified encoding.
41
+ def read_file(path):
42
+ """Read the file content.
48
43
 
49
44
  Args:
50
- path (str): Path to the file.
51
- encoding (str, optional): The encoding to use when reading the file. Defaults to "utf-8".
45
+ path (str): File path of source.
52
46
 
53
47
  Returns:
54
- str: The content of the file, or an empty string if the file could not be read.
55
- """
56
- try:
57
- with codecs.open(path, "r", encoding) as file_:
58
- return file_.read()
59
- except (OSError, IOError): # noqa: UP024
60
- return ""
48
+ str: The contents of the file path.
61
49
 
62
- def read_file(path):
63
- """Read the content of the file at the given path."""
64
- options = {"encoding": "utf-8"} if PY3 else {}
65
- with open(path, **options) as file_:
66
- try:
67
- content = file_.read()
68
- # maya-2022 UnicodeDecodeError from `plug-ins/mayaHIK.pres.mel`
69
- except UnicodeDecodeError:
70
- return ""
50
+ """
51
+ with open(path, "rb") as file_stream:
52
+ content = file_stream.read()
71
53
  return content
72
54
 
73
55
 
74
56
  def read_json(path):
75
57
  """Read the content of the file at the given path."""
76
- options = {"encoding": "utf-8"} if PY3 else {}
58
+ options = {"encoding": "utf-8"} if six.PY3 else {}
77
59
  with open(path, **options) as file_:
78
60
  try:
79
61
  content = json.load(file_)
@@ -84,13 +66,12 @@ def read_json(path):
84
66
 
85
67
  def write_file(path, content):
86
68
  """Write the given content to the file at the given path."""
87
- options = {"encoding": "utf-8"} if PY3 else {}
88
- with atomic_writes(path, "w", **options) as file_:
89
- file_.write(content)
69
+ with atomic_writes(path, "wb") as file_:
70
+ file_.write(six.ensure_binary(content))
90
71
 
91
72
 
92
73
  @contextmanager
93
- def atomic_writes(src, mode, **options):
74
+ def atomic_writes(src, mode):
94
75
  """Context manager for atomic writes to a file.
95
76
 
96
77
  This context manager ensures that the file is only written to disk if the write operation completes without errors.
@@ -107,15 +88,13 @@ def atomic_writes(src, mode, **options):
107
88
  AttributeError: If the os module does not have the 'replace' function (Python 2 compatibility).
108
89
  """
109
90
  temp_path = os.path.join(os.path.dirname(src), "._{}".format(id_generator()))
110
- open_func = open if PY3 else codecs.open
111
- with open_func(temp_path, mode, **options) as f:
91
+ with open(temp_path, mode) as f:
112
92
  yield f
113
93
  try:
114
94
  os.replace(temp_path, src)
115
95
  except AttributeError:
116
96
  shutil.move(temp_path, src)
117
97
 
118
-
119
98
  def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
120
99
  """Generate a random string of the given size using the given characters."""
121
100
  return "".join(random.choice(chars) for _ in range(size))
@@ -203,12 +182,7 @@ def remove_virus_file_by_signature(file_path, signatures, output_file_path=None,
203
182
  auto_remove: If True, remove the input file if the output file is empty.
204
183
 
205
184
  """
206
- try:
207
- data = read_file(file_path)
208
- except (OSError, IOError): # noqa: UP024
209
- return False
210
- except UnicodeDecodeError:
211
- data = _codes_open(file_path)
185
+ data = read_file(file_path)
212
186
  if check_virus_by_signature(data, signatures):
213
187
  fixed_data = replace_content_by_signatures(data, signatures).strip()
214
188
  if fixed_data:
@@ -230,7 +204,7 @@ def replace_content_by_signatures(content, signatures):
230
204
  str: The cleaned content.
231
205
  """
232
206
  for signature in signatures:
233
- content = re.sub(signature, "", content)
207
+ content = re.sub(*map(six.ensure_binary, [signature, "", content]))
234
208
  return content
235
209
 
236
210
 
@@ -250,7 +224,7 @@ def check_virus_file_by_signature(file_path, signatures=None):
250
224
  except (OSError, IOError): # noqa: UP024
251
225
  return False
252
226
  except UnicodeDecodeError:
253
- data = _codes_open(file_path)
227
+ data = ""
254
228
  return check_virus_by_signature(data, signatures)
255
229
 
256
230
 
@@ -266,7 +240,7 @@ def check_virus_by_signature(content, signatures=None):
266
240
  """
267
241
  signatures = signatures or FILE_VIRUS_SIGNATURES
268
242
  for signature in signatures:
269
- if re.search(signature, content):
243
+ if re.search(*map(six.ensure_binary, [signature, content])):
270
244
  return True
271
245
  return False
272
246
 
maya_umbrella/scanner.py CHANGED
@@ -6,6 +6,7 @@ import shutil
6
6
 
7
7
  # Import local modules
8
8
  from maya_umbrella import maya_funs
9
+ from maya_umbrella._vendor.six import PY2
9
10
  from maya_umbrella.defender import context_defender
10
11
  from maya_umbrella.filesystem import get_backup_path
11
12
  from maya_umbrella.filesystem import read_file
@@ -45,14 +46,23 @@ class MayaVirusScanner(object):
45
46
  "MAYA_COLOR_MANAGEMENT_SYNCOLOR": "1"
46
47
  }
47
48
 
48
- def scan_files_from_pattern(self, pattern):
49
+ def scan_files_from_pattern(self, pattern, glob_options=None):
49
50
  """Scan and fix Maya files matching a given pattern.
50
51
 
51
52
  Args:
52
53
  pattern (str): The file pattern to match.
54
+ glob_options (dict): Optional keyword arguments for the glob module.
55
+ if py3, we can pass a dict with the keyword arguments. {"recursive": True}
56
+
57
+ Raises:
58
+ ValueError: If py2, recursive is not supported.
59
+
53
60
  """
61
+ glob_options = glob_options or {}
62
+ if "recursive" in glob_options and PY2:
63
+ raise ValueError("recursive is not supported in python2")
54
64
  os.environ.update(self._env)
55
- return self.scan_files_from_list(glob.iglob(pattern))
65
+ return self.scan_files_from_list(glob.iglob(pattern, **glob_options))
56
66
 
57
67
  def scan_files_from_list(self, files):
58
68
  """Scan and fix Maya files from a given list.
@@ -8,3 +8,17 @@ VirusSignature = namedtuple("VirusSignature", ["name", "signature"])
8
8
  virus20240430_sig1 = VirusSignature("virus20240430", "python(.*);.+exec.+(pyCode).+;")
9
9
  # https://regex101.com/r/2D14UA/1
10
10
  virus20240430_sig2 = VirusSignature("virus20240430", r"^\['.+']")
11
+
12
+ JOB_SCRIPTS_VIRUS_SIGNATURES = [
13
+ "petri_dish_path.+cmds.internalVar.+",
14
+ "userSetup",
15
+ "fuckVirus",
16
+ virus20240430_sig1.signature,
17
+ virus20240430_sig2.signature,
18
+ ]
19
+
20
+ FILE_VIRUS_SIGNATURES = [
21
+ "import vaccine",
22
+ "cmds.evalDeferred.*leukocyte.+",
23
+ virus20240430_sig1.signature,
24
+ ]
@@ -2,12 +2,12 @@
2
2
  import os
3
3
 
4
4
  # Import local modules
5
- from maya_umbrella.constants import JOB_SCRIPTS_VIRUS_SIGNATURES
6
5
  from maya_umbrella.filesystem import check_virus_by_signature
7
6
  from maya_umbrella.filesystem import check_virus_file_by_signature
8
7
  from maya_umbrella.maya_funs import check_reference_node_exists
9
8
  from maya_umbrella.maya_funs import cmds
10
9
  from maya_umbrella.maya_funs import get_attr_value
10
+ from maya_umbrella.signatures import JOB_SCRIPTS_VIRUS_SIGNATURES
11
11
  from maya_umbrella.vaccine import AbstractVaccine
12
12
 
13
13
 
@@ -3,13 +3,13 @@ import glob
3
3
  import os
4
4
 
5
5
  # Import local modules
6
- from maya_umbrella.constants import JOB_SCRIPTS_VIRUS_SIGNATURES
7
6
  from maya_umbrella.filesystem import check_virus_by_signature
8
7
  from maya_umbrella.filesystem import check_virus_file_by_signature
9
8
  from maya_umbrella.maya_funs import cmds
10
9
  from maya_umbrella.maya_funs import get_attr_value
11
10
  from maya_umbrella.maya_funs import get_reference_file_by_node
12
11
  from maya_umbrella.maya_funs import is_maya_standalone
12
+ from maya_umbrella.signatures import JOB_SCRIPTS_VIRUS_SIGNATURES
13
13
  from maya_umbrella.vaccine import AbstractVaccine
14
14
 
15
15
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maya_umbrella
3
- Version: 0.10.0
3
+ Version: 0.11.0
4
4
  Summary: Check and fix maya virus.
5
5
  Home-page: https://github.com/loonghao/maya_umbrella
6
6
  License: MIT
@@ -0,0 +1,35 @@
1
+ maya_umbrella/__init__.py,sha256=rcCnFWmELeJsGoKvLHyzC_GmZu-eT1QXjQCHRGj6HuQ,529
2
+ maya_umbrella/__version__.py,sha256=raMu9XA9JEjvdoTmFqcOw7qhJX24rYDP7XmS59TAO-Q,23
3
+ maya_umbrella/_vendor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ maya_umbrella/_vendor/six/__init__.pyi,sha256=tU6T1qIa_1HEM5lYdk7qw9E3GdDokvpzy5D06PhlMfA,18
5
+ maya_umbrella/_vendor/six/moves/__init__.pyi,sha256=jVS195D1cetBSWcwZ61-NYkaaI-EKlXjoF1o0I_pG9I,24
6
+ maya_umbrella/_vendor/six/moves/configparser.pyi,sha256=OOloYod0yM3pPe0YlqnFSkiWejxtFwN-Gs0YPYHY1Nc,37
7
+ maya_umbrella/_vendor/six.LICENSE,sha256=i7hQxWWqOJ_cFvOkaWWtI9gq3_YPI5P8J2K2MYXo5sk,1066
8
+ maya_umbrella/_vendor/six.py,sha256=TOOfQi7nFGfMrIvtdr6wX4wyHH8M7aknmuLfo2cBBrM,34549
9
+ maya_umbrella/_vendor/vendor.txt,sha256=DaF4-6IabevawSU5v0lD3Cyskkkzge3-659bvqihS34,12
10
+ maya_umbrella/cleaner.py,sha256=Xj8BU0gohvh3E7RcDwQw_xryCzN5RBYGH9UTPVxiMPA,5045
11
+ maya_umbrella/collector.py,sha256=rAFmvY8Isdle89ezn2-H36hSJd77iBvPBLRPzruCycA,13111
12
+ maya_umbrella/constants.py,sha256=SuD8OP8e0Kh3a9ohyS5_MXjo5pHNQ8MWEPtJ6puZfIU,130
13
+ maya_umbrella/defender.py,sha256=eT4uK23uOB1V8Y3uiaU1C2Tp-s1SngrGo3TWDbSIVJY,6008
14
+ maya_umbrella/filesystem.py,sha256=fB7UNXzorC-878LgPd3CvQQuLxbjicnOR2y7AjAldeA,9535
15
+ maya_umbrella/hooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ maya_umbrella/hooks/delete_turtle.py,sha256=OPFRFH1iwonHvETndrP87MZQlJLhxpe564AJE3KyJY8,761
17
+ maya_umbrella/hooks/delete_unknown_plugin_node.py,sha256=5YXaOem-t9Em1sr3wmBqWk5He1Lm8CsOMQsSQ3ixLfs,1293
18
+ maya_umbrella/hooks/fix_model_panel.py,sha256=dLuMOz5uQ1nqAboNWMCx-Bi_gHM3FQNTlGxPG5wRYEs,556
19
+ maya_umbrella/hooks/fix_on_model_change_3dc.py,sha256=o4WEQPcHNzaTMXdNnHZWWNCYlHfLxcSFYXR4YW0ZLwk,484
20
+ maya_umbrella/i18n.py,sha256=aWaIncHh5Zq02hErMbHHLoQm_8Fu-YfBWQ15sUgsBJk,2642
21
+ maya_umbrella/locales/en_US.json,sha256=LW2gPgO2YJIYR5UfcIBuxW_DS7rf4gkjeVuADqs1V5s,962
22
+ maya_umbrella/locales/zh_CN.json,sha256=UsuRN2yaxxc9LE-7NQkbMqrkjXjNhNegS0QRkQLSTiE,1006
23
+ maya_umbrella/log.py,sha256=8CY_sCPOmxDOY2oHLZel2QjZiY4HsXKwVu9vNWmScTc,1379
24
+ maya_umbrella/maya_funs.py,sha256=_4LaMO4cRTCcbgNj2ei7UtSLAnCRY_ylHiLGKgvM4sE,3652
25
+ maya_umbrella/scanner.py,sha256=2z9ugJbwr4-4_aXCozkgzb4htBPa8PVPnw_S12S-isE,4419
26
+ maya_umbrella/signatures.py,sha256=GmsqpGa98WLg1ZeixxVEcTypveM0kc5dA5kb56y9kVI,658
27
+ maya_umbrella/vaccine.py,sha256=aBW6pdT4tD4OMBPZ-d3E4_n16Rylz-2gb7JWzMZVPK0,1022
28
+ maya_umbrella/vaccines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ maya_umbrella/vaccines/vaccine1.py,sha256=WLo1uJElTLSjVCf5CBtRNU4HKs63my5mkHiGqTfnNEE,489
30
+ maya_umbrella/vaccines/vaccine2.py,sha256=qYiI_-BSojgN7j4esYCGBDLeyBSneDOGUwZhKHccxh8,2170
31
+ maya_umbrella/vaccines/vaccine3.py,sha256=AgYxpflStURawobBQX0F0N_4uDwyV1IWCvZ6QLMmKpA,3633
32
+ maya_umbrella-0.11.0.dist-info/LICENSE,sha256=tJf0Pz8q_65AjEkm3872K1cl4jGil28vJO5Ko_LhUqc,1060
33
+ maya_umbrella-0.11.0.dist-info/METADATA,sha256=b0Yc0GlH7LrTX-ugh1xASQawXTZvbx3bUUINerUv3l0,11722
34
+ maya_umbrella-0.11.0.dist-info/WHEEL,sha256=IrRNNNJ-uuL1ggO5qMvT1GGhQVdQU54d6ZpYqEZfEWo,92
35
+ maya_umbrella-0.11.0.dist-info/RECORD,,
@@ -1,28 +0,0 @@
1
- maya_umbrella/__init__.py,sha256=rcCnFWmELeJsGoKvLHyzC_GmZu-eT1QXjQCHRGj6HuQ,529
2
- maya_umbrella/__version__.py,sha256=v4zmKjsKOPZbp6BrWoz7iK4ST0sdZdUh9bQSJmluZ5o,23
3
- maya_umbrella/cleaner.py,sha256=5EC3w4qRkIsr9AIZneEV8ljhxaOw385Gj2C2KTrzyJg,5044
4
- maya_umbrella/collector.py,sha256=rAFmvY8Isdle89ezn2-H36hSJd77iBvPBLRPzruCycA,13111
5
- maya_umbrella/constants.py,sha256=2sl0dL0U82mwu-Msda9B8-USxr89Wu2yu6SYiuaaJZk,539
6
- maya_umbrella/defender.py,sha256=eT4uK23uOB1V8Y3uiaU1C2Tp-s1SngrGo3TWDbSIVJY,6008
7
- maya_umbrella/filesystem.py,sha256=AnKUDw6N1xU0YO4YaTiLzl88Ju7MYezetcyn87Te1iY,10442
8
- maya_umbrella/hooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- maya_umbrella/hooks/delete_turtle.py,sha256=OPFRFH1iwonHvETndrP87MZQlJLhxpe564AJE3KyJY8,761
10
- maya_umbrella/hooks/delete_unknown_plugin_node.py,sha256=5YXaOem-t9Em1sr3wmBqWk5He1Lm8CsOMQsSQ3ixLfs,1293
11
- maya_umbrella/hooks/fix_model_panel.py,sha256=dLuMOz5uQ1nqAboNWMCx-Bi_gHM3FQNTlGxPG5wRYEs,556
12
- maya_umbrella/hooks/fix_on_model_change_3dc.py,sha256=o4WEQPcHNzaTMXdNnHZWWNCYlHfLxcSFYXR4YW0ZLwk,484
13
- maya_umbrella/i18n.py,sha256=aWaIncHh5Zq02hErMbHHLoQm_8Fu-YfBWQ15sUgsBJk,2642
14
- maya_umbrella/locales/en_US.json,sha256=LW2gPgO2YJIYR5UfcIBuxW_DS7rf4gkjeVuADqs1V5s,962
15
- maya_umbrella/locales/zh_CN.json,sha256=UsuRN2yaxxc9LE-7NQkbMqrkjXjNhNegS0QRkQLSTiE,1006
16
- maya_umbrella/log.py,sha256=8CY_sCPOmxDOY2oHLZel2QjZiY4HsXKwVu9vNWmScTc,1379
17
- maya_umbrella/maya_funs.py,sha256=_4LaMO4cRTCcbgNj2ei7UtSLAnCRY_ylHiLGKgvM4sE,3652
18
- maya_umbrella/scanner.py,sha256=pDU6RKez19kaaO_7HE4jG4h53XoloPCwiuVV8ajr2mo,3932
19
- maya_umbrella/signatures.py,sha256=RkEXChch7tdqA9Yq6YQ8AMnK2ra6ih0dfnpeZy5FkYs,354
20
- maya_umbrella/vaccine.py,sha256=aBW6pdT4tD4OMBPZ-d3E4_n16Rylz-2gb7JWzMZVPK0,1022
21
- maya_umbrella/vaccines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- maya_umbrella/vaccines/vaccine1.py,sha256=WLo1uJElTLSjVCf5CBtRNU4HKs63my5mkHiGqTfnNEE,489
23
- maya_umbrella/vaccines/vaccine2.py,sha256=b2OmYjLCZRFIeeVr-EvQRrmYIGmTX4J9l9DtINAmo7E,2169
24
- maya_umbrella/vaccines/vaccine3.py,sha256=LAP5QfDIlbiUM_A7O2Vnw4aFhDtojd2kAo2CFcHOKVE,3632
25
- maya_umbrella-0.10.0.dist-info/LICENSE,sha256=tJf0Pz8q_65AjEkm3872K1cl4jGil28vJO5Ko_LhUqc,1060
26
- maya_umbrella-0.10.0.dist-info/METADATA,sha256=Tzf4ZBeqxgfvzer_rRMO1cZWgapHoeF0vFVgqonoZsI,11722
27
- maya_umbrella-0.10.0.dist-info/WHEEL,sha256=IrRNNNJ-uuL1ggO5qMvT1GGhQVdQU54d6ZpYqEZfEWo,92
28
- maya_umbrella-0.10.0.dist-info/RECORD,,