return TYPE_STRING
-# Designates a metadata field type and checks that it matches
-#
-# 'name' - The long name of the field type
-# 'matching' - List of possible values or regex expression
-# 'sep' - Separator to use if value may be a list
-# 'fields' - Metadata fields (Field:Value) of this type
-# 'flags' - Build flags (flag=value) of this type
-#
class FieldValidator():
+ """
+ Designates App metadata field types and checks that it matches
+
+ 'name' - The long name of the field type
+ 'matching' - List of possible values or regex expression
+ 'sep' - Separator to use if value may be a list
+ 'fields' - Metadata fields (Field:Value) of this type
+ """
- def __init__(self, name, matching, fields, flags):
+ def __init__(self, name, matching, fields):
self.name = name
self.matching = matching
self.compiled = re.compile(matching)
self.fields = fields
- self.flags = flags
def check(self, v, appid):
if not v:
# Generic value types
valuetypes = {
- FieldValidator("Integer",
- r'^[1-9][0-9]*$',
- [],
- ['vercode']),
-
FieldValidator("Hexadecimal",
r'^[0-9a-f]+$',
- ['FlattrID'],
- []),
+ ['FlattrID']),
FieldValidator("HTTP link",
r'^http[s]?://',
- ["WebSite", "SourceCode", "IssueTracker", "Changelog", "Donate"], []),
+ ["WebSite", "SourceCode", "IssueTracker", "Changelog", "Donate"]),
FieldValidator("Email",
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
- ["AuthorEmail"], []),
+ ["AuthorEmail"]),
FieldValidator("Bitcoin address",
r'^[a-zA-Z0-9]{27,34}$',
- ["Bitcoin"],
- []),
+ ["Bitcoin"]),
FieldValidator("Litecoin address",
r'^L[a-zA-Z0-9]{33}$',
- ["Litecoin"],
- []),
+ ["Litecoin"]),
FieldValidator("Repo Type",
r'^(git|git-svn|svn|hg|bzr|srclib)$',
- ["RepoType"],
- []),
+ ["RepoType"]),
FieldValidator("Binaries",
r'^http[s]?://',
- ["Binaries"],
- []),
+ ["Binaries"]),
FieldValidator("Archive Policy",
r'^[0-9]+ versions$',
- ["ArchivePolicy"],
- []),
+ ["ArchivePolicy"]),
FieldValidator("Anti-Feature",
r'^(Ads|Tracking|NonFreeNet|NonFreeDep|NonFreeAdd|UpstreamNonFree|NonFreeAssets|KnownVuln)$',
- ["AntiFeatures"],
- []),
+ ["AntiFeatures"]),
FieldValidator("Auto Update Mode",
r"^(Version .+|None)$",
- ["AutoUpdateMode"],
- []),
+ ["AutoUpdateMode"]),
FieldValidator("Update Check Mode",
r"^(Tags|Tags .+|RepoManifest|RepoManifest/.+|RepoTrunk|HTTP|Static|None)$",
- ["UpdateCheckMode"],
- [])
+ ["UpdateCheckMode"])
}
if k not in app._modified:
continue
v.check(app.__dict__[k], app.id)
- for build in app.builds:
- for k in v.flags:
- if k not in build._modified:
- continue
- v.check(build.__dict__[k], app.id)
# Formatter for descriptions. Create an instance, and call parseline() with
build = Build()
build.version = parts[0]
build.vercode = parts[1]
+ check_versionCode(build.vercode)
+
if parts[2].startswith('!'):
# For backwards compatibility, handle old-style disabling,
# including attempting to extract the commit from the message
return build
+ def check_versionCode(versionCode):
+ try:
+ int(versionCode)
+ except ValueError:
+ warn_or_exception('Invalid versionCode: "' + versionCode + '" is not an integer!')
+
def add_comments(key):
if not curcomments:
return
build = Build()
build.version = vv[0]
build.vercode = vv[1]
+ check_versionCode(build.vercode)
if build.vercode in vc_seen:
warn_or_exception('Duplicate build recipe found for vercode %s in %s'
% (build.vercode, linedesc))