Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
f3eaf01c
Kaydet (Commit)
f3eaf01c
authored
Şub 17, 2001
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More modifications to bring the script output in line with the real thing.
üst
63cb99e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
unweave.py
Mac/scripts/unweave.py
+34
-4
No files found.
Mac/scripts/unweave.py
Dosyayı görüntüle @
f3eaf01c
...
@@ -10,9 +10,10 @@ import macostools
...
@@ -10,9 +10,10 @@ import macostools
BEGINDEFINITION
=
re
.
compile
(
"^<<(?P<name>.*)>>=
\
s*"
)
BEGINDEFINITION
=
re
.
compile
(
"^<<(?P<name>.*)>>=
\
s*"
)
USEDEFINITION
=
re
.
compile
(
"^(?P<pre>.*)<<(?P<name>.*)>>(?P<post>[^=].*)"
)
USEDEFINITION
=
re
.
compile
(
"^(?P<pre>.*)<<(?P<name>.*)>>(?P<post>[^=].*)"
)
ENDDEFINITION
=
re
.
compile
(
"^@"
)
ENDDEFINITION
=
re
.
compile
(
"^@"
)
GREMLINS
=
re
.
compile
(
"[
\xa0\xca
]"
)
DEFAULT_CONFIG
=
"""
DEFAULT_CONFIG
=
"""
config
= [
filepatterns
= [
("^.*
\
.cp$", ":unweave-src"),
("^.*
\
.cp$", ":unweave-src"),
("^.*
\
.h$", ":unweave-include"),
("^.*
\
.h$", ":unweave-include"),
]
]
...
@@ -38,6 +39,13 @@ class Processor:
...
@@ -38,6 +39,13 @@ class Processor:
self
.
gencomments
=
config
[
"gencomments"
]
self
.
gencomments
=
config
[
"gencomments"
]
else
:
else
:
self
.
gencomments
=
0
self
.
gencomments
=
0
if
config
.
has_key
(
"filepatterns"
):
self
.
filepatterns
=
config
[
"filepatterns"
]
else
:
self
.
filepatterns
=
[]
self
.
filepattern_relist
=
[]
for
pat
,
dummy
in
self
.
filepatterns
:
self
.
filepattern_relist
.
append
(
re
.
compile
(
pat
))
def
_readline
(
self
):
def
_readline
(
self
):
"""Read a line. Allow for pushback"""
"""Read a line. Allow for pushback"""
...
@@ -100,9 +108,16 @@ class Processor:
...
@@ -100,9 +108,16 @@ class Processor:
savedcomment
=
savedcomment
+
[(
lineno
,
'//
\n
'
)]
+
defline
savedcomment
=
savedcomment
+
[(
lineno
,
'//
\n
'
)]
+
defline
else
:
else
:
savedcomment
=
defline
savedcomment
=
defline
savedcomment
=
self
.
_
extendlines
(
savedcomment
)
savedcomment
=
self
.
_
processcomment
(
savedcomment
)
value
=
savedcomment
+
value
value
=
savedcomment
+
value
savedcomment
=
[]
savedcomment
=
[]
isfilepattern
=
0
for
rexp
in
self
.
filepattern_relist
:
if
rexp
.
search
(
name
):
isfilepattern
=
1
break
if
0
and
not
isfilepattern
:
value
=
self
.
_addspace
(
value
)
self
.
_define
(
name
,
value
)
self
.
_define
(
name
,
value
)
else
:
else
:
if
self
.
gencomments
:
if
self
.
gencomments
:
...
@@ -110,17 +125,25 @@ class Processor:
...
@@ -110,17 +125,25 @@ class Processor:
if
savedcomment
or
line
.
strip
():
if
savedcomment
or
line
.
strip
():
savedcomment
.
append
((
lineno
,
'// '
+
line
))
savedcomment
.
append
((
lineno
,
'// '
+
line
))
def
_
extendlines
(
self
,
comment
):
def
_
processcomment
(
self
,
comment
):
# This routine mimicks some artefact of Matthias' code.
# This routine mimicks some artefact of Matthias' code.
rv
=
[]
rv
=
[]
for
lineno
,
line
in
comment
:
for
lineno
,
line
in
comment
:
line
=
line
[:
-
1
]
line
=
line
[:
-
1
]
line
=
GREMLINS
.
subn
(
' '
,
line
)[
0
]
if
len
(
line
)
<
75
:
if
len
(
line
)
<
75
:
line
=
line
+
(
75
-
len
(
line
))
*
' '
line
=
line
+
(
75
-
len
(
line
))
*
' '
line
=
line
+
'
\n
'
line
=
line
+
'
\n
'
rv
.
append
((
lineno
,
line
))
rv
.
append
((
lineno
,
line
))
return
rv
return
rv
def
_addspace
(
self
,
value
,
howmany
):
# Yet another routine to mimick yet another artefact
rv
=
value
[
0
:
1
]
for
lineno
,
line
in
value
[
1
:]:
rv
.
append
((
lineno
,
(
' '
*
howmany
)
+
line
))
return
rv
def
resolve
(
self
):
def
resolve
(
self
):
"""Resolve all references"""
"""Resolve all references"""
for
name
in
self
.
items
.
keys
():
for
name
in
self
.
items
.
keys
():
...
@@ -141,15 +164,22 @@ class Processor:
...
@@ -141,15 +164,22 @@ class Processor:
# No rest for the wicked: we have work to do.
# No rest for the wicked: we have work to do.
self
.
resolving
[
name
]
=
1
self
.
resolving
[
name
]
=
1
result
=
[]
result
=
[]
lastlineincomplete
=
0
for
lineno
,
line
in
self
.
items
[
name
]:
for
lineno
,
line
in
self
.
items
[
name
]:
mo
=
USEDEFINITION
.
search
(
line
)
mo
=
USEDEFINITION
.
search
(
line
)
if
mo
:
if
mo
:
# We replace the complete line. Is this correct?
# We replace the complete line. Is this correct?
macro
=
mo
.
group
(
'name'
)
macro
=
mo
.
group
(
'name'
)
replacement
=
self
.
_resolve_one
(
macro
)
replacement
=
self
.
_resolve_one
(
macro
)
if
lastlineincomplete
:
replacement
=
self
.
_addspace
(
replacement
,
lastlineincomplete
)
result
=
result
+
replacement
result
=
result
+
replacement
else
:
else
:
result
.
append
((
lineno
,
line
))
result
.
append
((
lineno
,
line
))
if
line
[
-
1
]
==
'
\n
'
:
lastlineincomplete
=
0
else
:
lastlineincomplete
=
len
(
line
)
self
.
items
[
name
]
=
result
self
.
items
[
name
]
=
result
self
.
resolved
[
name
]
=
1
self
.
resolved
[
name
]
=
1
del
self
.
resolving
[
name
]
del
self
.
resolving
[
name
]
...
@@ -194,7 +224,7 @@ def process(file, config):
...
@@ -194,7 +224,7 @@ def process(file, config):
pr
=
Processor
(
file
,
config
)
pr
=
Processor
(
file
,
config
)
pr
.
read
()
pr
.
read
()
pr
.
resolve
()
pr
.
resolve
()
for
pattern
,
folder
in
config
[
'
config
'
]:
for
pattern
,
folder
in
config
[
'
filepatterns
'
]:
pr
.
save
(
folder
,
pattern
)
pr
.
save
(
folder
,
pattern
)
def
readconfig
():
def
readconfig
():
...
...
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