Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
e09bbd99
Commit
e09bbd99
authored
Apr 06, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
bd67a3af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
0 deletions
+95
-0
lib/python/Setup
lib/python/Setup
+1
-0
lib/python/ts_regex.py
lib/python/ts_regex.py
+94
-0
No files found.
lib/python/Setup
View file @
e09bbd99
...
...
@@ -2,3 +2,4 @@
# install Main.py
# install Globals.py
# install ImageFile.py
# install ts_regex.py
lib/python/ts_regex.py
0 → 100644
View file @
e09bbd99
import
regex
,
regsub
from
regex
import
*
from
regsub
import
split
,
sub
,
gsub
,
splitx
,
capwords
try
:
import
thread
,
Sync
class
compile
:
_r
=
None
def
__init__
(
self
,
*
args
):
self
.
_r
=
r
=
apply
(
regex
.
compile
,
args
)
self
.
search
=
r
.
search
self
.
match
=
r
.
match
def
search_group
(
self
,
str
,
group
,
pos
=
0
):
"""Search a string for a pattern.
If the pattern was not found, then None is returned,
otherwise, the location where the pattern was found,
as well as any specified group are returned.
"""
r
=
self
.
_r
l
=
r
.
search
(
str
,
pos
)
if
l
<
0
:
return
None
return
l
,
apply
(
r
.
group
,
group
)
def
match_group
(
self
,
str
,
group
,
pos
=
0
):
"""Match a pattern against a string
If the string does not match the pattern, then None is
returned, otherwise, the length of the match, as well
as any specified group are returned.
"""
r
=
self
.
_r
l
=
r
.
match
(
str
,
pos
)
if
l
<
0
:
return
None
return
l
,
apply
(
r
.
group
,
group
)
def
search_regs
(
self
,
str
,
pos
=
0
):
"""Search a string for a pattern.
If the pattern was not found, then None is returned,
otherwise, the 'regs' attribute of the expression is
returned.
"""
r
=
self
.
_r
r
.
search
(
str
,
pos
)
return
r
.
regs
def
match_regs
(
self
,
str
,
pos
=
0
):
"""Match a pattern against a string
If the string does not match the pattern, then None is
returned, otherwise, the 'regs' attribute of the expression is
returned.
"""
r
=
self
.
_r
r
.
match
(
str
,
pos
)
return
r
.
regs
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
_r
,
name
)
class
symcomp
(
compile
):
def
__init__
(
self
,
*
args
):
self
.
_r
=
r
=
apply
(
regex
.
symcomp
,
args
)
self
.
search
=
r
.
search
self
.
match
=
r
.
match
class
SafeFunction
:
def
__init__
(
self
,
f
):
self
.
_f
=
f
l
=
thread
.
allocate_lock
()
self
.
_a
=
l
.
acquire
self
.
_r
=
l
.
release
def
__call__
(
self
,
*
args
,
**
kw
):
self
.
_a
()
try
:
return
apply
(
self
.
_f
,
args
,
kw
)
finally
:
self
.
_r
()
split
=
SafeFunction
(
split
)
sub
=
SafeFunction
(
sub
)
gsub
=
SafeFunction
(
gsub
)
splitx
=
SafeFunction
(
splitx
)
capwords
=
SafeFunction
(
capwords
)
except
:
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment