Skip to content

Commit 6674c67

Browse files
author
invincibleqc
committed
Removed memory.helpers.open_ini_file...
1 parent 1a1239b commit 6674c67

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

addons/source-python/packages/source-python/memory/helpers.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
'Array',
2323
'MemberFunction',
2424
'parse_data',
25-
'NO_DEFAULT',
26-
'open_ini_file'
25+
'NO_DEFAULT'
2726
]
2827

2928

@@ -426,25 +425,3 @@ def parse_data(raw_data, keys):
426425
# Use this as a default value if the key is not allowed to have a default
427426
# value
428427
NO_DEFAULT = object()
429-
430-
def open_ini_file(f):
431-
'''
432-
Opens an *.ini file with ConfigObj and tries to call a close() method.
433-
434-
If the given file does not exist a FileNotFoundError will be raised.
435-
'''
436-
437-
# Does the file exists?
438-
if not path(f).isfile():
439-
raise FileNotFoundError('No such file: {0}'.format(f))
440-
441-
# Read the data
442-
data = ConfigObj(f)
443-
444-
# Try to close the file. Maybe it was an url or a file object
445-
try:
446-
f.close()
447-
except AttributeError:
448-
pass
449-
450-
return data

addons/source-python/packages/source-python/memory/manager.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# =============================================================================
22
# >> IMPORTS
33
# =============================================================================
4+
# Python Imports
5+
# ConfigObj
6+
from configobj import ConfigObj
7+
48
# Source.Python
59
from memory import *
610
from memory.helpers import *
@@ -227,7 +231,7 @@ def create_pipe_from_file(self, f):
227231
'''
228232

229233
# Read the data
230-
raw_data = open_ini_file(f)
234+
raw_data = ConfigObj(f, file_error=True)
231235

232236
# Prepare functions
233237
funcs = parse_data(
@@ -277,7 +281,7 @@ def create_type_from_file(self, type_name, f, bases=(CustomType,)):
277281
'''
278282

279283
# Read the data
280-
raw_data = open_ini_file(f)
284+
raw_data = ConfigObj(f, file_error=True)
281285

282286
# Prepare general type information
283287
data = tuple(parse_data(
@@ -625,7 +629,7 @@ def create_function_typedefs_from_file(self, f):
625629
'''
626630

627631
# Read the data
628-
raw_data = open_ini_file(f)
632+
raw_data = ConfigObj(f, file_error=True)
629633

630634
# Prepare typedefs
631635
typedefs = parse_data(
@@ -670,7 +674,7 @@ def create_global_pointers_from_file(self, f):
670674

671675
# Parse pointer data
672676
pointers = parse_data(
673-
open_ini_file(f),
677+
ConfigObj(f, file_error=True),
674678
(
675679
(Key.BINARY, str, NO_DEFAULT),
676680
(Key.IDENTIFIER, Key.as_identifier, NO_DEFAULT),

0 commit comments

Comments
 (0)