Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sébastien Villemot
website
Commits
a7fd5ba1
Commit
a7fd5ba1
authored
Oct 19, 2018
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
python script to read RePEc .rdf files and create _data/wp.yml
parent
9623782c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
_config.yml
+1
-0
1 addition, 0 deletions
_config.yml
assets/RePEc/rdf2yml.py
+92
-0
92 additions, 0 deletions
assets/RePEc/rdf2yml.py
wp/index.md
+1
-1
1 addition, 1 deletion
wp/index.md
wp/list.md
+1
-1
1 addition, 1 deletion
wp/list.md
with
95 additions
and
2 deletions
_config.yml
+
1
−
0
View file @
a7fd5ba1
...
...
@@ -167,6 +167,7 @@ exclude:
-
/assets/images/logo/*.pdf
-
/assets/images/logo/*.tex
-
/assets/images/logo/*.sh
-
/assets/RePEc/rdf2yml.py
keep_files
:
-
.git
-
/assets/images/*
...
...
This diff is collapsed.
Click to expand it.
assets/RePEc/rdf2yml.py
0 → 100644
+
92
−
0
View file @
a7fd5ba1
import
os
import
re
import
sys
# Parse .rdf files
wp_first_year
=
2011
wps
=
dict
()
wp_year
=
wp_first_year
while
True
:
filename
=
'
dynare-
'
+
str
(
wp_year
)
+
'
.rdf
'
if
not
os
.
path
.
isfile
(
filename
):
break
fh
=
open
(
filename
,
'
r
'
)
wpn
=
-
1
wp
=
dict
()
authors
=
[]
urls
=
[]
url_function
=
[]
for
line
in
fh
:
spl
=
re
.
split
(
'
[:]
'
,
line
)
key
=
spl
[
0
]
if
key
==
'
Template-Type
'
or
key
==
'
# Local Variables
'
:
if
wpn
>=
1
:
wp
[
'
urls
'
]
=
urls
wp
[
'
url_function
'
]
=
url_function
wp
[
'
authors
'
]
=
authors
wps
[
wpn
]
=
wp
wpn
=
-
1
wp
=
dict
()
authors
=
[]
urls
=
[]
url_function
=
[]
elif
key
==
'
Number
'
:
wpn
=
int
(
spl
[
1
])
elif
key
==
'
Title
'
:
wp
[
'
title
'
]
=
"
:
"
.
join
(
spl
[
1
:]).
strip
()
elif
key
==
'
File-URL
'
:
urls
.
append
(
'
:
'
.
join
((
spl
[
1
:])).
strip
())
elif
key
==
'
File-Function
'
:
url_function
.
append
(
spl
[
1
].
strip
())
elif
key
==
'
Creation-Date
'
:
spl
=
re
.
split
(
'
[-]
'
,
spl
[
1
])
wp
[
'
year
'
]
=
int
(
spl
[
0
])
elif
key
==
'
Author-Name
'
:
authors
.
append
(
spl
[
1
].
strip
())
fh
.
close
()
wp_year
+=
1
# Write .yml file
yml
=
open
(
'
wp.yml
'
,
'
w
'
)
for
key
in
sorted
(
wps
,
reverse
=
True
):
yml
.
write
(
'
- number: {:d}
\n
'
.
format
(
key
))
yml
.
write
(
'
authors:
'
)
firstauthor
=
True
for
author
in
wps
[
key
][
'
authors
'
]:
name
=
author
.
split
(
'
,
'
)
last
=
name
[
0
]
first
=
"
"
.
join
(
name
[
1
:]).
strip
()
if
firstauthor
:
firstauthor
=
False
else
:
yml
.
write
(
'
,
'
)
yml
.
write
(
'
{:s} {:s}
'
.
format
(
first
,
last
))
yml
.
write
(
'
\n
'
)
yml
.
write
(
'
title:
"
{:s}
"
\n
'
.
format
(
wps
[
key
][
'
title
'
]))
yml
.
write
(
'
year: {:d}
\n
'
.
format
(
wps
[
key
][
'
year
'
]))
# Have to do this because some entries are mal-formed (do not contain File-Function info)
if
len
(
wps
[
key
][
'
urls
'
])
==
1
:
yml
.
write
(
'
url: {:s}
\n
'
.
format
(
wps
[
key
][
'
urls
'
][
0
]))
else
:
for
idx
,
url
in
enumerate
(
wps
[
key
][
'
urls
'
]):
if
wps
[
key
][
'
url_function
'
][
idx
]
==
'
Main text
'
:
yml
.
write
(
'
url: {:s}
\n
'
.
format
(
wps
[
key
][
'
urls
'
][
idx
]))
elif
wps
[
key
][
'
url_function
'
][
idx
]
==
'
Data used in the paper
'
:
yml
.
write
(
'
data_url: {:s}
\n
'
.
format
(
wps
[
key
][
'
urls
'
][
idx
]))
elif
wps
[
key
][
'
url_function
'
][
idx
]
==
'
Source code of programs used in the paper
'
or
\
wps
[
key
][
'
url_function
'
][
idx
]
==
'
Dynare source code used in the paper
'
:
yml
.
write
(
'
source_url: {:s}
\n
'
.
format
(
wps
[
key
][
'
urls
'
][
idx
]))
else
:
print
(
wps
[
key
])
print
(
'
Unhandled url case: {:s}
'
.
format
(
wps
[
key
][
'
url_function
'
][
idx
]))
sys
.
exit
()
yml
.
write
(
'
\n
'
)
yml
.
close
()
print
(
'
Done writing wp.yml
'
)
This diff is collapsed.
Click to expand it.
wp/index.md
+
1
−
1
View file @
a7fd5ba1
...
...
@@ -12,7 +12,7 @@ title: Working Papers
<ol
reversed
start=
"{{ latestwp }}"
>
{% for wp in site.data.wp limit:5 %}
<li>
{{ wp.authors }} ({{ wp.year }}), "
<a
href=
"
http://www.dynare.org/wp-repo/dynarewp0{{ wp.number }}.pdf
"
>
{{ wp.title }}
</a>
"
{{ wp.authors }} ({{ wp.year }}), "
<a
href=
"
{{ wp.url }}
"
>
{{ wp.title }}
</a>
"
{% if wp.source_url %}(
<a
href=
"{{ wp.source_url }}"
>
source
</a>
){% endif %}
{% if wp.data_url %}(
<a
href=
"{{ wp.data_url }}"
>
data
</a>
){% endif %}
</li>
...
...
This diff is collapsed.
Click to expand it.
wp/list.md
+
1
−
1
View file @
a7fd5ba1
...
...
@@ -12,7 +12,7 @@ title: Working Papers
<ol
reversed
start=
"{{ latestwp }}"
>
{% for wp in site.data.wp %}
<li>
{{ wp.authors }} ({{ wp.year }}), "
<a
href=
"
http://www.dynare.org/wp-repo/dynarewp0{{ wp.number }}.pdf
"
>
{{ wp.title }}
</a>
"
{{ wp.authors }} ({{ wp.year }}), "
<a
href=
"
{{ wp.url }}
"
>
{{ wp.title }}
</a>
"
{% if wp.source_url %}(
<a
href=
"{{ wp.source_url }}"
>
source
</a>
){% endif %}
{% if wp.data_url %}(
<a
href=
"{{ wp.data_url }}"
>
data
</a>
){% endif %}
</li>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment