Commit 8f1d4699 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Handle version string spaces in enum generator

parent 0386adef
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -108,11 +108,18 @@ def prefix_version(match: re.Match) -> str:
	return 'v' + match.group()


@substitutor(r"[ ](v|pre-)[0-9]\S*(?:[ ]or[ ])? | [0-9][ ]or[ ]", re.VERBOSE)
def underscore_version(match: re.Match) -> str:
	"""
	Replace spaces in version strings with underscores
	"""
	return match.group().replace(' ', '_')


@substitutor(
	r"""
	(?:
		  (?P<version>[ ]v[0-9]\S*(?:[ ]or[ ])? | [0-9][ ]or[ ])
		| (?P<bad>^[^a-z_+#]+|[^a-z0-9_+#]+)
		  (?P<bad>^[^a-z_+#]+|[^a-z0-9_+#]+)
		| (?P<taggable>[+#]+)
	)
	(?P<post>[a-z0-9_]|$)
@@ -130,10 +137,6 @@ def replace_misidentifiers(match: re.Match) -> str:
	pre = match.string[start - 1:start] if start > 0 else ''
	post = match.group('post')

	version = match.group('version')
	if version:
		return version.replace(' ', '_') + post

	if pre and post:
		if pre.isdigit() or pre.isupper() or post.isdigit():
			post = '_' + post
@@ -175,6 +178,7 @@ def get_identifiers(label: str) -> List[str]:

	# If a version string, prefix with 'v'
	name = prefix_version(name)
	name = underscore_version(name)

	# separate the contents of parentheses
	match = PAREN_RE.search(name)
+2 −2
Original line number Diff line number Diff line
@@ -475,7 +475,7 @@ class OperatingSystem(Classifier):
		class Windows(Classifier, classifier="Operating System :: Microsoft :: Windows"):

			Windows_10 = "Operating System :: Microsoft :: Windows :: Windows 10"
			Windows_3_1_orEarlier = "Operating System :: Microsoft :: Windows :: Windows 3.1 or Earlier"
			Windows_3_1_or_Earlier = "Operating System :: Microsoft :: Windows :: Windows 3.1 or Earlier"
			Windows_7 = "Operating System :: Microsoft :: Windows :: Windows 7"
			Windows_8 = "Operating System :: Microsoft :: Windows :: Windows 8"
			Windows_8_1 = "Operating System :: Microsoft :: Windows :: Windows 8.1"
@@ -719,7 +719,7 @@ class Topic(Classifier):
			class Sawfish(Classifier, classifier="Topic :: Desktop Environment :: Window Managers :: Sawfish"):

				Themes_0_30 = "Topic :: Desktop Environment :: Window Managers :: Sawfish :: Themes 0.30"
				ThemesPre_0_30 = "Topic :: Desktop Environment :: Window Managers :: Sawfish :: Themes pre-0.30"
				Themes_pre_0_30 = "Topic :: Desktop Environment :: Window Managers :: Sawfish :: Themes pre-0.30"

			class Waimea(Classifier, classifier="Topic :: Desktop Environment :: Window Managers :: Waimea"):