GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MAINT: De-dupe regex usage · wangtingpython/zipline@6d83b06

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • setup.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎setup.py‎

Copy file name to clipboardExpand all lines: setup.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ def _with_bounds(req):
133133
return ''.join(with_bounds)
134134

135135

136+
REQ_PATTERN = re.compile("([^=<>]+)([<=>]{1,2})(.*)")
137+
138+
136139
def _conda_format(req):
137-
return re.sub(
138-
'([^=<>]+)([=<>]{1,2})',
139-
lambda m: '%s %s' % (m.group(1).lower(), m.group(2)),
140-
req,
141-
1,
140+
return REQ_PATTERN.sub(
141+
lambda m: '%s %s%s' % (m.group(1).lower(), m.group(2), m.group(3)),
142+
req,
143+
1,
142144
)
143145

144146

@@ -184,14 +186,12 @@ def module_requirements(requirements_path, module_names):
184186
module_names = set(module_names)
185187
found = set()
186188
module_lines = []
187-
parser = re.compile("([^=<>]+)([<=>]{1,2})(.*)")
188189
for line in read_requirements(requirements_path, strict_bounds=True):
189-
match = parser.match(line)
190+
match = REQ_PATTERN.match(line)
190191
if match is None:
191192
raise AssertionError("Could not parse requirement: '%s'" % line)
192193

193-
groups = match.groups()
194-
name = groups[0]
194+
name = match.group(1)
195195
if name in module_names:
196196
found.add(name)
197197
module_lines.append(line)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.