Skip to content

Commit

Permalink
some basic tools: we use the wiki as base format
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jul 28, 2012
1 parent 22492be commit 93df67a
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 29 deletions.
26 changes: 1 addition & 25 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg
wiki
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all:

build: wiki
cd wiki && git pull

wiki:
git clone git@github.com:grammarware/ruconf.wiki.git wiki
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
ruconf
======

Международные научные конференции
См. http://github.com/grammarware/ruconf/wiki
76 changes: 76 additions & 0 deletions create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os, sys
import urllib, urllib2, httplib, socket
rel = {}

def exists(url):
try:
s = urllib.urlopen(url).read()
except IOError,e:
return False
except socket.error,e:
return False
if s.find('was not found on this server') < 0:
return True
return False

def determine(s):
if s.find('Workshop') > -1:
return 'ws'
elif s.find('Working conference') > -1:
return 'wc'
elif s.find('Working Conference') > -1:
return 'wc'
elif s.find('International conference') > -1:
return 'ic'
elif s.find('International Conference') > -1:
return 'ic'
elif s.find('Symposium') > -1:
return 'sy'
else:
return 'ic'

def explode(s):
if s == 'ic':
return '[[International Conference|международная конференция]]'
elif s == 'wc':
return '[[Working Conference|рабочая конференция]]'
elif s == 'ws':
return '[[Workshop|рабочая встреча]]'
elif s == 'sy':
return '[[Symposium|Симпозиум]]'
else:
return 'ERROR'

if __name__ == '__main__':
if len(sys.argv) < 2:
print 'Create what?'
sys.exit(-1)
name = sys.argv[1]
fname = 'wiki/%s.wiki' % name
print 'Creating %s...' % name
if os.path.exists(fname):
print 'Already exists.'
sys.exit(1)
f = open(fname,'w')
fullname = raw_input("Full name? ")
f.write("* Название: '''%s'''\n" % fullname)
f.write("* Перевод: '''%s'''\n" % raw_input("Translation? "))
status = determine(fullname)
s = raw_input("Status[%s]? " % status)
if s:
status = s
f.write('* Статус: %s\n' % explode(status))
f.write('\n== Тематика ==\n* …\n\n== Ссылки ==\n')
dblp = name.lower()
while not exists('http://dblp.uni-trier.de/db/conf/%s/index.html' % dblp):
dblp = raw_input("DBLP[%s]? " % dblp)
# s = urllib.urlopen('http://dblp.uni-trier.de/db/conf/%s/index.html' %s dblp).read()
f.write('* [http://dblp.uni-trier.de/db/conf/%s/ %s] на [[DBLP]]\n' % (dblp, name))
acad = raw_input("Academic? ")
if acad:
f.write('* [http://academic.research.microsoft.com/Conference/%s/ %s] на [[Academic]]\n' % (acad, name))
f.close()
print 'Yes.'
34 changes: 34 additions & 0 deletions dblp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys, urllib, urllib2, httplib, socket

if __name__ == '__main__':
if len(sys.argv) < 2:
print 'Crawl what?'
sys.exit(-1)
name = sys.argv[1]
f = open('wiki/%s.wiki' % name, 'r')
content = f.read()
dblp = content.split(' %s] на [[DBLP]]' % name)[0].split('[')[-1]
s = urllib.urlopen(dblp).read()
lst = []
c = {}
for h2 in s.split('<h2>')[1:]:
lst.append(h2.split('</h2>')[0])
c[lst[-1]] = []
for cnt in h2.split('">Contents</a>')[:-1]:
c[lst[-1]].append(cnt.split('"')[-1])
print 'Crawling...'
f.close()
c1,c2 = content.split('== Ссылки ==')
f = open('wiki/%s.wiki' % name, 'w')
f.write(c1)
f.write('== Архив ==\n')
for s in lst:
f.write('* %s\n' % s)
for cnt in c[s]:
f.write('** [%s DBLP]\n' % (dblp+cnt))
f.write('\n== Ссылки ==')
f.write(c2)
f.close()
print 'Done.'

0 comments on commit 93df67a

Please sign in to comment.