cue4parse 0.0.4__tar.gz → 0.0.5__tar.gz

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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cue4parse
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: CUE4Parse Python wrapper and CLI tool to extract packages from Unreal Engine games
5
5
  Project-URL: Homepage, https://github.com/joric/CUE4Parse-Python/wiki
6
6
  Project-URL: Repository, https://github.com/joric/CUE4Parse-Python
@@ -20,11 +20,4 @@ Description-Content-Type: text/markdown
20
20
 
21
21
  CUE4Parse Python wrapper, CLI tool, and scripting engine
22
22
 
23
- ## Usage
24
-
25
- `pip install cue4parse`
26
-
27
- * Make sure executable is added to paths, e.g. `%LOCALAPPDATA%\Python\pythoncore-3.14-64\Scripts`.
28
- * Needs CUE4Parse libraries in `%LOCALAPPDATA%/cue4parse/libs` (downloads and unpacks FModel on Windows).
29
- * To run CLI: `cue4parse`
30
-
23
+ * Documentation: https://github.com/joric/CUE4Parse-Python/wiki
@@ -0,0 +1,5 @@
1
+ # CUE4Parse-Python
2
+
3
+ CUE4Parse Python wrapper, CLI tool, and scripting engine
4
+
5
+ * Documentation: https://github.com/joric/CUE4Parse-Python/wiki
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "cue4parse"
7
- version = "0.0.4"
7
+ version = "0.0.5"
8
8
  description = "CUE4Parse Python wrapper and CLI tool to extract packages from Unreal Engine games"
9
9
  requires-python = ">=3.9"
10
10
  dependencies = ["pythonnet>=3.0"]
@@ -191,9 +191,9 @@ def execute(options: CliOptions) -> int:
191
191
  overwrite_files = options.yes
192
192
 
193
193
  if options.verbose:
194
- Log.Logger = with_console(LoggerConfiguration().MinimumLevel.Verbose()).CreateLogger()
194
+ Log.Logger = LoggerConfiguration().MinimumLevel.Verbose().WriteTo.Console().CreateLogger()
195
195
  else:
196
- Log.Logger = with_console(LoggerConfiguration().MinimumLevel.Fatal()).CreateLogger()
196
+ Log.Logger = LoggerConfiguration().MinimumLevel.Fatal().WriteTo.Console().CreateLogger()
197
197
 
198
198
  try:
199
199
  game_version = parse_enum(EGame, options.game, "GAME_UE5_LATEST")
@@ -0,0 +1,110 @@
1
+ from __future__ import annotations
2
+
3
+ import fnmatch
4
+ import json
5
+ import logging
6
+ import os
7
+ import sys
8
+ import time
9
+ from dataclasses import dataclass
10
+ from enum import Flag, auto
11
+ from pathlib import Path
12
+ from typing import Any, Iterable
13
+
14
+ from cue4parse import _DLL_DIR
15
+
16
+ def _find_dotnet_root() -> Path | None:
17
+ candidates = [
18
+ Path.home() / ".dotnet",
19
+ Path("/usr/share/dotnet"),
20
+ Path("/usr/lib/dotnet"),
21
+ ]
22
+ for candidate in candidates:
23
+ if (candidate / "host" / "fxr").exists():
24
+ return candidate
25
+ return None
26
+
27
+ def _find_runtime_config() -> str | None:
28
+ libs_dir = Path(__file__).parent / "libs"
29
+ configs = list(libs_dir.glob("*.runtimeconfig.json"))
30
+ return str(configs[0]) if configs else None
31
+
32
+ dotnet_root = _find_dotnet_root()
33
+ if dotnet_root:
34
+ os.environ["DOTNET_ROOT"] = str(dotnet_root)
35
+
36
+ import pythonnet
37
+
38
+ runtime_config = _find_runtime_config()
39
+ if runtime_config:
40
+ pythonnet.load("coreclr", runtime_config=runtime_config)
41
+ else:
42
+ pythonnet.load("coreclr")
43
+
44
+ import clr
45
+
46
+ libs_dir = _DLL_DIR
47
+ cue4parse_dll_dir = str(libs_dir)
48
+ sys.path.append(cue4parse_dll_dir)
49
+
50
+ clr.AddReference("CUE4Parse")
51
+ clr.AddReference("CUE4Parse-Conversion")
52
+
53
+ clr.AddReference("System")
54
+ clr.AddReference("System.Core")
55
+ clr.AddReference("Newtonsoft.Json")
56
+
57
+ # enable logger
58
+
59
+ clr.AddReference("Serilog")
60
+ clr.AddReference("Serilog.Sinks.Console")
61
+
62
+ import System
63
+ from Serilog import Log, LoggerConfiguration
64
+ from Serilog.Configuration import LoggerSinkConfiguration
65
+ from Serilog.Events import LogEventLevel
66
+
67
+ def patch_serilog_console() -> None:
68
+ flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static
69
+ sink_type = clr.GetClrType(LoggerSinkConfiguration)
70
+ logger_type = clr.GetClrType(LoggerConfiguration)
71
+ assembly = System.Reflection.Assembly.Load("Serilog.Sinks.Console")
72
+
73
+ console_method = next(
74
+ method
75
+ for typ in assembly.GetTypes()
76
+ for method in typ.GetMethods(flags)
77
+ if method.Name == "Console"
78
+ and (params := method.GetParameters())
79
+ and params[0].ParameterType == sink_type
80
+ )
81
+
82
+ parent_field = next(
83
+ field
84
+ for field in sink_type.GetFields(
85
+ System.Reflection.BindingFlags.Public
86
+ | System.Reflection.BindingFlags.NonPublic
87
+ | System.Reflection.BindingFlags.Instance
88
+ )
89
+ if field.FieldType == logger_type
90
+ )
91
+
92
+ def console(self, *args, **kwargs):
93
+ overrides = {"standardErrorFromLevel": LogEventLevel.Verbose, **kwargs}
94
+ positional = (self, *args)
95
+ values = [
96
+ overrides[p.Name]
97
+ if p.Name in overrides
98
+ else positional[i]
99
+ if i < len(positional)
100
+ else System.Type.Missing
101
+ for i, p in enumerate(console_method.GetParameters())
102
+ ]
103
+ console_method.Invoke(None, System.Array[System.Object](values))
104
+ return parent_field.GetValue(self)
105
+
106
+ setattr(LoggerSinkConfiguration, "Console", console)
107
+
108
+ patch_serilog_console()
109
+
110
+ Log.Logger = LoggerConfiguration().MinimumLevel.Verbose().WriteTo.Console().CreateLogger()
@@ -1,4 +1,4 @@
1
- import time
1
+ import time, sys
2
2
  from cue4parse import *
3
3
 
4
4
  GAME_DIR = r"E:\Games\Subnautica2\Subnautica2\Content\Paks"
@@ -7,7 +7,7 @@ MAPPINGS_FILE = r"E:\Games\Subnautica2\Subnautica2.usmap"
7
7
  def main():
8
8
  start = time.perf_counter()
9
9
 
10
- Log.Logger = with_console(LoggerConfiguration().MinimumLevel.Verbose()).CreateLogger()
10
+ Log.Logger = LoggerConfiguration().MinimumLevel.Verbose().WriteTo.Console().CreateLogger()
11
11
 
12
12
  version = VersionContainer(EGame.GAME_UE5_6, ETexturePlatform.DesktopMobile)
13
13
  provider = DefaultFileProvider(GAME_DIR, SearchOption.TopDirectoryOnly, version, StringComparer.OrdinalIgnoreCase)
@@ -24,15 +24,14 @@ def main():
24
24
 
25
25
  exports = package.GetExports()
26
26
 
27
- name_filter = lambda name: 'Lifepod' in str(name)
27
+ filter = lambda name: 'Lifepod' in str(name)
28
28
 
29
29
  for export in exports:
30
- name = str(export)
31
- if not name_filter(name):
30
+ if not filter(export.ExportType):
32
31
  continue
33
- print(export.ExportType)
32
+ print(export.ExportType, export.Name)
34
33
 
35
- print(f'Finished in {time.perf_counter() - start:.4f}s')
34
+ print(f'Finished in {time.perf_counter() - start:.4f}s', file=sys.stderr)
36
35
 
37
36
  if __name__ == '__main__':
38
37
  raise SystemExit(main())
@@ -31,4 +31,3 @@ from CUE4Parse_Conversion.Textures import ETextureFormat, TextureDecoder, Textur
31
31
  from CUE4Parse_Conversion.Textures.BC import DetexHelper
32
32
  from CUE4Parse_Conversion.UEFormat.Enums import EFileCompressionFormat
33
33
  from CUE4Parse.UE4.Assets.Exports.Material import EMaterialFormat
34
-
cue4parse-0.0.4/README.md DELETED
@@ -1,12 +0,0 @@
1
- # CUE4Parse-Python
2
-
3
- CUE4Parse Python wrapper, CLI tool, and scripting engine
4
-
5
- ## Usage
6
-
7
- `pip install cue4parse`
8
-
9
- * Make sure executable is added to paths, e.g. `%LOCALAPPDATA%\Python\pythoncore-3.14-64\Scripts`.
10
- * Needs CUE4Parse libraries in `%LOCALAPPDATA%/cue4parse/libs` (downloads and unpacks FModel on Windows).
11
- * To run CLI: `cue4parse`
12
-
@@ -1,90 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import fnmatch
4
- import json
5
- import logging
6
- import os
7
- import sys
8
- import time
9
- from dataclasses import dataclass
10
- from enum import Flag, auto
11
- from pathlib import Path
12
- from typing import Any, Iterable
13
-
14
- from cue4parse import _DLL_DIR
15
-
16
- def _find_dotnet_root() -> Path | None:
17
- candidates = [
18
- Path.home() / ".dotnet",
19
- Path("/usr/share/dotnet"),
20
- Path("/usr/lib/dotnet"),
21
- ]
22
- for candidate in candidates:
23
- if (candidate / "host" / "fxr").exists():
24
- return candidate
25
- return None
26
-
27
- def _find_runtime_config() -> str | None:
28
- libs_dir = Path(__file__).parent / "libs"
29
- configs = list(libs_dir.glob("*.runtimeconfig.json"))
30
- return str(configs[0]) if configs else None
31
-
32
- dotnet_root = _find_dotnet_root()
33
- if dotnet_root:
34
- os.environ["DOTNET_ROOT"] = str(dotnet_root)
35
-
36
- import pythonnet
37
-
38
- runtime_config = _find_runtime_config()
39
- if runtime_config:
40
- pythonnet.load("coreclr", runtime_config=runtime_config)
41
- else:
42
- pythonnet.load("coreclr")
43
-
44
- import clr
45
-
46
- libs_dir = _DLL_DIR
47
- cue4parse_dll_dir = str(libs_dir)
48
- sys.path.append(cue4parse_dll_dir)
49
-
50
- clr.AddReference("CUE4Parse")
51
- clr.AddReference("CUE4Parse-Conversion")
52
-
53
- clr.AddReference("System")
54
- clr.AddReference("System.Core")
55
- clr.AddReference("Newtonsoft.Json")
56
-
57
- clr.AddReference("Serilog")
58
- clr.AddReference("Serilog.Sinks.Console")
59
-
60
- import System
61
- from Serilog import Log, LoggerConfiguration
62
- from Serilog.Events import LogEventLevel
63
- from Serilog.Configuration import LoggerSinkConfiguration
64
-
65
- def with_console(cfg: LoggerConfiguration) -> LoggerConfiguration:
66
- asm = System.Reflection.Assembly.Load("Serilog.Sinks.Console")
67
- bf = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static
68
- lsc_t = clr.GetClrType(LoggerSinkConfiguration)
69
- for t in asm.GetTypes():
70
- if not (t.IsSealed and t.IsAbstract):
71
- continue
72
- for m in t.GetMethods(bf):
73
- if m.Name != "Console":
74
- continue
75
- ps = m.GetParameters()
76
- if len(ps) >= 1 and ps[0].ParameterType == lsc_t:
77
- args = [System.Type.Missing] * len(ps)
78
- args[0] = cfg.WriteTo
79
- # Find and set the standardErrorFromLevel parameter so it's stderr, not stdout
80
- for i, p in enumerate(ps):
81
- if p.Name == "standardErrorFromLevel":
82
- lel_t = System.Type.GetType("Serilog.Events.LogEventLevel, Serilog")
83
- args[i] = System.Enum.Parse(lel_t, "Verbose")
84
- break
85
- m.Invoke(None, System.Array[System.Object](args))
86
- return cfg
87
- raise RuntimeError("Serilog console sink extension method not found")
88
-
89
- # you can re-define it in user code later with Verbose() or any other level
90
- Log.Logger = with_console(LoggerConfiguration().MinimumLevel.Fatal()).CreateLogger()
File without changes
File without changes