This commit is contained in:
Frank DeMarco 2013-04-14 17:18:52 +09:00
parent 3a7155fa87
commit 7bfb1a5b37
4 changed files with 19 additions and 19 deletions

View File

@ -8,13 +8,13 @@ from ConfigParser import RawConfigParser
class Configuration(RawConfigParser):
default_project_file_rel_path = "config"
default_resources_paths = [".", "resources"]
default_resource_paths = [".", "resource"]
def __init__(self, project_file_rel_path=None, resources_path=None,
def __init__(self, project_file_rel_path=None, resource_path=None,
type_declarations=None):
RawConfigParser.__init__(self)
self.project_file_rel_path = project_file_rel_path
self.resources_path = resources_path
self.resource_path = resource_path
self.set_type_declarations(type_declarations)
self.set_defaults()
self.read_project_config_file()
@ -41,7 +41,7 @@ class Configuration(RawConfigParser):
set_option(section, "additional-packages", "")
set_option(section, "title", "")
set_option(section, "classifiers", "")
set_option(section, "resources-search-path", "./, resources/")
set_option(section, "resource-search-path", "./, resource/")
set_option(section, "installation-dir", "/usr/local/share/games/")
set_option(section, "changelog", "changelog")
set_option(section, "description-file", "")
@ -55,7 +55,7 @@ class Configuration(RawConfigParser):
set_option(section, "url", "")
set_option(section, "requirements", "")
set_option(section, "main-object", "pgfw/Game.py")
set_option(section, "resources-path-identifier", "resources_path")
set_option(section, "resource-path-identifier", "resource_path")
set_option(section, "special-char-placeholder", "_")
set_option(section, "whitespace-placeholder", "-")
set_option(section, "windows-dist-path", "dist/win/")
@ -126,8 +126,8 @@ class Configuration(RawConfigParser):
rel_path = self.default_project_file_rel_path
if exists(rel_path) and not self.is_shared_mode():
return rel_path
if self.resources_path:
installed_path = join(self.resources_path, rel_path)
if self.resource_path:
installed_path = join(self.resource_path, rel_path)
if exists(installed_path):
return installed_path
@ -143,7 +143,7 @@ class Configuration(RawConfigParser):
def modify_defaults(self):
self.set_installation_path()
self.set_resources_search_path()
self.set_resource_search_path()
self.set_screen_captures_path()
self.set_data_exclusion_list()
self.set_requirements()
@ -153,11 +153,11 @@ class Configuration(RawConfigParser):
join(self.get("setup", "installation-dir"),
self.get("setup", "package-root")))
def set_resources_search_path(self):
section, option = "setup", "resources-search-path"
def set_resource_search_path(self):
section, option = "setup", "resource-search-path"
search_path = self.get(section, option)
if self.resources_path:
search_path.append(self.resources_path)
if self.resource_path:
search_path.append(self.resource_path)
else:
search_path.append(self.get("setup", "installation-path"))
self.set(section, option, search_path)
@ -265,7 +265,7 @@ class TypeDeclarations(dict):
"screen-captures": {"path": "path"},
"setup": {"list": ["classifiers", "resources-search-path",
"setup": {"list": ["classifiers", "resource-search-path",
"requirements", "data-exclude",
"additional-packages"],

View File

@ -13,7 +13,7 @@ from ScreenGrabber import ScreenGrabber
class Game(GameChild):
resources_path = None
resource_path = None
def __init__(self, config_rel_path=None, type_declarations=None):
GameChild.__init__(self)
@ -29,7 +29,7 @@ class Game(GameChild):
def set_configuration(self):
self.configuration = Configuration(self.config_rel_path,
self.resources_path,
self.resource_path,
self.type_declarations)
def set_children(self):

View File

@ -49,7 +49,7 @@ class GameChild:
def get_resource(self, section, option):
config = self.get_configuration()
rel_path = config.get(section, option)
for root in config.get("setup", "resources-search-path"):
for root in config.get("setup", "resource-search-path"):
if self.is_shared_mode() and not self.is_absolute_path(root):
continue
path = join(root, rel_path)

View File

@ -93,7 +93,7 @@ class Setup:
scripts = []
if config["init-script"]:
scripts.append(config["init-script"])
setup(cmdclass={"install": insert_resources_path},
setup(cmdclass={"install": insert_resource_path},
name=self.translate_title(),
packages=self.build_package_list(),
scripts=scripts,
@ -112,7 +112,7 @@ class Setup:
options=options)
class insert_resources_path(install):
class insert_resource_path(install):
def run(self):
install.run(self)
@ -124,7 +124,7 @@ class insert_resources_path(install):
if path.endswith(config["main-object"]):
for line in FileInput(path, inplace=True):
pattern = "^ *{0} *=.*".\
format(config["resources-path-identifier"])
format(config["resource-path-identifier"])
if match(pattern, line):
line = sub("=.*$", "= \"{0}\"".\
format(config["installation-path"]), line)