[game-data-packager] 02/09: Move types that support the build process to a new module
Simon McVittie
smcv at debian.org
Thu Oct 1 10:16:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit c446e944b7ac8c9f59beacf177f9d69c3e38a3df
Author: Simon McVittie <smcv at debian.org>
Date: Thu Oct 1 09:49:52 2015 +0100
Move types that support the build process to a new module
Eventually, the actual package-building should go there too, but for
now this lets non-main modules use the enum and exceptions.
---
game_data_packager/__init__.py | 61 +++------------------------------
game_data_packager/build.py | 78 ++++++++++++++++++++++++++++++++++++++++++
tools/babel.py | 3 +-
tools/stats.py | 3 +-
4 files changed, 87 insertions(+), 58 deletions(-)
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 0582bba..7b20f5d 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -17,7 +17,6 @@
# /usr/share/common-licenses/GPL-2.
from collections import defaultdict
-from enum import Enum
import argparse
import glob
import hashlib
@@ -42,6 +41,11 @@ from debian.deb822 import Deb822
from debian.debian_support import Version
import yaml
+from .build import (CDRipFailed,
+ DownloadNotAllowed,
+ DownloadsFailed,
+ FillResult,
+ NoPackagesPossible)
from .config import read_config
from .gog import GOG
from .paths import DATADIR, ETCDIR
@@ -75,61 +79,6 @@ QUITE_LARGE = 50 * MEBIBYTE
MD5SUM_DIVIDER = re.compile(r' [ *]?')
-class FillResult(Enum):
- UNDETERMINED = 0
- IMPOSSIBLE = 1
- DOWNLOAD_NEEDED = 2
- COMPLETE = 3
- UPGRADE_NEEDED = 4
-
- def __and__(self, other):
- if other is FillResult.UNDETERMINED:
- return self
-
- if self is FillResult.UNDETERMINED:
- return other
-
- if other is FillResult.IMPOSSIBLE or self is FillResult.IMPOSSIBLE:
- return FillResult.IMPOSSIBLE
-
- if other is FillResult.UPGRADE_NEEDED or self is FillResult.UPGRADE_NEEDED:
- return FillResult.UPGRADE_NEEDED
-
- if other is FillResult.DOWNLOAD_NEEDED or self is FillResult.DOWNLOAD_NEEDED:
- return FillResult.DOWNLOAD_NEEDED
-
- return FillResult.COMPLETE
-
- def __or__(self, other):
- if other is FillResult.UNDETERMINED:
- return self
-
- if self is FillResult.UNDETERMINED:
- return other
-
- if other is FillResult.COMPLETE or self is FillResult.COMPLETE:
- return FillResult.COMPLETE
-
- if other is FillResult.DOWNLOAD_NEEDED or self is FillResult.DOWNLOAD_NEEDED:
- return FillResult.DOWNLOAD_NEEDED
-
- if other is FillResult.UPGRADE_NEEDED or self is FillResult.UPGRADE_NEEDED:
- return FillResult.UPGRADE_NEEDED
-
- return FillResult.IMPOSSIBLE
-
-class NoPackagesPossible(Exception):
- pass
-
-class DownloadsFailed(Exception):
- pass
-
-class DownloadNotAllowed(Exception):
- pass
-
-class CDRipFailed(Exception):
- pass
-
class HashedFile(object):
def __init__(self, name):
self.name = name
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
new file mode 100644
index 0000000..d4a8a36
--- /dev/null
+++ b/game_data_packager/build.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python3
+# encoding=utf-8
+#
+# Copyright © 2014-2015 Simon McVittie <smcv at debian.org>
+# Copyright © 2015 Alexandre Detiste <alexandre at detiste.be>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# You can find the GPL license text on a Debian system under
+# /usr/share/common-licenses/GPL-2.
+
+from enum import Enum
+import logging
+
+logging.basicConfig()
+logger = logging.getLogger('game-data-packager.build')
+
+class FillResult(Enum):
+ UNDETERMINED = 0
+ IMPOSSIBLE = 1
+ DOWNLOAD_NEEDED = 2
+ COMPLETE = 3
+ UPGRADE_NEEDED = 4
+
+ def __and__(self, other):
+ if other is FillResult.UNDETERMINED:
+ return self
+
+ if self is FillResult.UNDETERMINED:
+ return other
+
+ if other is FillResult.IMPOSSIBLE or self is FillResult.IMPOSSIBLE:
+ return FillResult.IMPOSSIBLE
+
+ if other is FillResult.UPGRADE_NEEDED or self is FillResult.UPGRADE_NEEDED:
+ return FillResult.UPGRADE_NEEDED
+
+ if other is FillResult.DOWNLOAD_NEEDED or self is FillResult.DOWNLOAD_NEEDED:
+ return FillResult.DOWNLOAD_NEEDED
+
+ return FillResult.COMPLETE
+
+ def __or__(self, other):
+ if other is FillResult.UNDETERMINED:
+ return self
+
+ if self is FillResult.UNDETERMINED:
+ return other
+
+ if other is FillResult.COMPLETE or self is FillResult.COMPLETE:
+ return FillResult.COMPLETE
+
+ if other is FillResult.DOWNLOAD_NEEDED or self is FillResult.DOWNLOAD_NEEDED:
+ return FillResult.DOWNLOAD_NEEDED
+
+ if other is FillResult.UPGRADE_NEEDED or self is FillResult.UPGRADE_NEEDED:
+ return FillResult.UPGRADE_NEEDED
+
+ return FillResult.IMPOSSIBLE
+
+class NoPackagesPossible(Exception):
+ pass
+
+class DownloadsFailed(Exception):
+ pass
+
+class DownloadNotAllowed(Exception):
+ pass
+
+class CDRipFailed(Exception):
+ pass
diff --git a/tools/babel.py b/tools/babel.py
index 00865bd..652d6fe 100755
--- a/tools/babel.py
+++ b/tools/babel.py
@@ -18,7 +18,8 @@
# Online at http://pkg-games.alioth.debian.org/game-data/
-from game_data_packager import (load_games, GameData, FillResult)
+from game_data_packager import (load_games, GameData)
+from game_data_packager.build import (FillResult)
games = []
genres = dict()
diff --git a/tools/stats.py b/tools/stats.py
index f08c904..3c0a2be 100755
--- a/tools/stats.py
+++ b/tools/stats.py
@@ -15,7 +15,8 @@
# You can find the GPL license text on a Debian system under
# /usr/share/common-licenses/GPL-2.
-from game_data_packager import (load_games, GameData, FillResult)
+from game_data_packager import (load_games, GameData)
+from game_data_packager.build import (FillResult)
games = []
for name, game in load_games().items():
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list