back to oxlib, package_dir does not work with pip/python setup.py develop

This commit is contained in:
j 2009-10-12 17:36:33 +02:00
parent bfc33beda5
commit 0f232e01cb
7 changed files with 37 additions and 37 deletions

View file

@ -3,12 +3,12 @@
import os import os
from django.conf import settings from django.conf import settings
from ox.cache import readUrlUnicode from oxlib.cache import readUrlUnicode
from ox import findRe from oxlib import findRe
import ox.web.criterion import oxweb.criterion
import ox.web.karagarga import oxweb.karagarga
import ox.web.imdb import oxweb.imdb
import ox.web.impawards import oxweb.impawards
import models import models
from oxdata.poster.models import PosterCache from oxdata.poster.models import PosterCache
@ -19,10 +19,10 @@ def addPoster(m, url, site, site_id):
p.save() p.save()
def getIds(): def getIds():
for id in ox.web.impawards.getIds(): for id in oxweb.impawards.getIds():
if models.MovieId.objects.all().filter(impawards_id=id).count() == 0: if models.MovieId.objects.all().filter(impawards_id=id).count() == 0:
print 'impawards', id print 'impawards', id
data = ox.web.impawards.getData(id) data = oxweb.impawards.getData(id)
if data and 'imdbId' in data: if data and 'imdbId' in data:
m = models.getMovieIdByImdbId(data['imdbId']) m = models.getMovieIdByImdbId(data['imdbId'])
if not m.impawards_id: if not m.impawards_id:
@ -31,10 +31,10 @@ def getIds():
for poster in data['posters']: for poster in data['posters']:
addPoster(m, poster, 'impawards.com', m.imdb_id) addPoster(m, poster, 'impawards.com', m.imdb_id)
for id in ox.web.criterion.getIds(): for id in oxweb.criterion.getIds():
if models.MovieId.objects.all().filter(criterion_id=id).count() == 0: if models.MovieId.objects.all().filter(criterion_id=id).count() == 0:
print 'criterion', id print 'criterion', id
data = ox.web.criterion.getData(id) data = oxweb.criterion.getData(id)
if data and 'imdbId' in data: if data and 'imdbId' in data:
m = models.getMovieIdByImdbId(data['imdbId']) m = models.getMovieIdByImdbId(data['imdbId'])
if not m.criterion_id: if not m.criterion_id:
@ -46,10 +46,10 @@ def getIds():
#kg #kg
lastId = models.Karagarga.maxId() lastId = models.Karagarga.maxId()
for id in ox.web.karagarga.getIds(lastId): for id in oxweb.karagarga.getIds(lastId):
if models.Karagarga.objects.filter(karagarga_id=id).count() == 0: if models.Karagarga.objects.filter(karagarga_id=id).count() == 0:
print 'kg', id print 'kg', id
data = ox.web.karagarga.getData(id) data = oxweb.karagarga.getData(id)
if data and 'imdbId' in data: if data and 'imdbId' in data:
m = models.getMovieIdByImdbId(data['imdbId']) m = models.getMovieIdByImdbId(data['imdbId'])
kg = models.Karagarga() kg = models.Karagarga()

View file

@ -8,9 +8,9 @@ from django.db.models import Q, Max
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils import simplejson from django.utils import simplejson
import ox.web.wikipedia import oxweb.wikipedia
import ox.web.imdb import oxweb.imdb
from ox import stripTags from oxlib import stripTags
def getMovieIdByImdbId(imdb_id): def getMovieIdByImdbId(imdb_id):
@ -56,8 +56,8 @@ class MovieId(models.Model):
def updateFromWikipedia(self): def updateFromWikipedia(self):
if self.wikipedia_id: if self.wikipedia_id:
wikipedia_url = ox.web.wikipedia.getUrl(self.wikipedia_id) wikipedia_url = oxweb.wikipedia.getUrl(self.wikipedia_id)
data = ox.web.wikipedia.getMovieData(wikipedia_url) data = oxweb.wikipedia.getMovieData(wikipedia_url)
_key = {} _key = {}
for key in ('imdb_id', 'amg_id'): for key in ('imdb_id', 'amg_id'):
if key in data: if key in data:
@ -67,7 +67,7 @@ class MovieId(models.Model):
def updateFromImdb(self): def updateFromImdb(self):
if self.imdb_id: if self.imdb_id:
data = ox.web.imdb.getMovieInfo(self.imdb_id) data = oxweb.imdb.getMovieInfo(self.imdb_id)
_key = { _key = {
'episode title': 'episode_title', 'episode title': 'episode_title',
'series title': 'series_title', 'series title': 'series_title',
@ -76,12 +76,12 @@ class MovieId(models.Model):
if key in data and data[key]: if key in data and data[key]:
setattr(self, _key.get(key, key), data[key]) setattr(self, _key.get(key, key), data[key])
directors = [] directors = []
credits = ox.web.imdb.getMovieCredits(self.imdb_id) credits = oxweb.imdb.getMovieCredits(self.imdb_id)
if 'directors' in credits: if 'directors' in credits:
directors = credits['directors'] directors = credits['directors']
self.director = ', '.join([stripTags(d[0]) for d in directors]) self.director = ', '.join([stripTags(d[0]) for d in directors])
if not self.wikipedia_id: if not self.wikipedia_id:
self.wikipedia_id = ox.web.wikipedia.getId(ox.web.wikipedia.getUrlByImdb(self.imdb_id)) self.wikipedia_id = oxweb.wikipedia.getId(oxweb.wikipedia.getUrlByImdb(self.imdb_id))
if not self.oxdb_id: if not self.oxdb_id:
self.gen_oxdb_id() self.gen_oxdb_id()
self.save() self.save()

View file

@ -5,7 +5,7 @@ from django.db import models
from django.db.models import Q from django.db.models import Q
from django.contrib.auth.models import User from django.contrib.auth.models import User
from ox.django.shortcuts import render_to_json_response from oxdjango.shortcuts import render_to_json_response
def ids(request): def ids(request):
json = {} json = {}

View file

@ -8,11 +8,11 @@ from django.db.models import Q
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
import ox.web.criterion import oxweb.criterion
import ox.web.movieposterdb import oxweb.movieposterdb
import ox.web.karagarga import oxweb.karagarga
import ox.web.imdb import oxweb.imdb
import ox.web.impawards import oxweb.impawards
from oxdata.lookup.models import MovieId, Karagarga from oxdata.lookup.models import MovieId, Karagarga
@ -56,9 +56,9 @@ class PosterCache(models.Model):
def get(self): def get(self):
if not self.image and not self.failed: if not self.image and not self.failed:
try: try:
import ox.net import oxlib.net
name = hashlib.sha1(self.url).hexdigest() name = hashlib.sha1(self.url).hexdigest()
data = ox.net.readUrl(self.url) data = oxlib.net.readUrl(self.url)
self.image.save(name, ContentFile(data)) self.image.save(name, ContentFile(data))
except: except:
self.failed = True self.failed = True
@ -90,28 +90,28 @@ def getPosterUrls(m):
p.save() p.save()
if m.imdb_id: if m.imdb_id:
poster = ox.web.imdb.getMoviePoster(m.imdb_id) poster = oxweb.imdb.getMoviePoster(m.imdb_id)
if poster: if poster:
addPoster(poster, 'imdb.com', m.imdb_id) addPoster(poster, 'imdb.com', m.imdb_id)
for poster in ox.web.movieposterdb.getData(m.imdb_id)['posters']: for poster in oxweb.movieposterdb.getData(m.imdb_id)['posters']:
addPoster(poster, 'movieposterdb.com', m.imdb_id) addPoster(poster, 'movieposterdb.com', m.imdb_id)
if m.criterion_id: if m.criterion_id:
print 'criterion', m.criterion_id print 'criterion', m.criterion_id
for poster in ox.web.criterion.getData(m.criterion_id)['posters']: for poster in oxweb.criterion.getData(m.criterion_id)['posters']:
addPoster(poster, 'criterion.com', m.criterion_id) addPoster(poster, 'criterion.com', m.criterion_id)
if m.wikipedia_id: if m.wikipedia_id:
poster = ox.web.wikipedia.getPosterUrl(m.wikipedia_id) poster = oxweb.wikipedia.getPosterUrl(m.wikipedia_id)
if poster: if poster:
if PosterCache.objects.all().filter(url=poster).count() == 0: if PosterCache.objects.all().filter(url=poster).count() == 0:
addPoster(poster, 'wikipedia.org', m.wikipedia_id) addPoster(poster, 'wikipedia.org', m.wikipedia_id)
if m.impawards_id: if m.impawards_id:
data = ox.web.impawards.getData(m.impawards_id) data = oxweb.impawards.getData(m.impawards_id)
if data and 'imdbId' in data: if data and 'imdbId' in data:
for poster in data['posters']: for poster in data['posters']:
addPoster(poster, 'impawards.com', m.imdb_id) addPoster(poster, 'impawards.com', m.imdb_id)
for kg in Karagarga.objects.all().filter(movie_id=m): for kg in Karagarga.objects.all().filter(movie_id=m):
data = ox.web.karagarga.getData(kg.karagarga_id) data = oxweb.karagarga.getData(kg.karagarga_id)
if data: if data:
for poster in data['posters']: for poster in data['posters']:
addPoster(poster, 'karagarga.net', kg.karagarga_id) addPoster(poster, 'karagarga.net', kg.karagarga_id)

View file

@ -7,7 +7,7 @@ from django.contrib.auth.models import User
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404 from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext from django.template import RequestContext
from ox.django.shortcuts import render_to_json_response from oxdjango.shortcuts import render_to_json_response
from oxdata.lookup.models import MovieId from oxdata.lookup.models import MovieId
import models import models

View file

@ -1,6 +1,6 @@
-e svn+http://code.djangoproject.com/svn/django/branches/releases/1.1.X/#egg=django -e svn+http://code.djangoproject.com/svn/django/branches/releases/1.1.X/#egg=django
South==0.6.1 South==0.6.1
-e bzr+http://code.0xdb.org/python-ox/#egg=python-ox -e bzr+http://code.0xdb.org/python-oxlib/#egg=python-oxlib
-e bzr+http://code.0xdb.org/python-oxweb/#egg=python-oxweb -e bzr+file:///home/j/Projects/python-oxweb/#egg=python-oxweb
-e bzr+http://code.0xdb.org/python-oxdjango/#egg=python-oxdjango -e bzr+http://code.0xdb.org/python-oxdjango/#egg=python-oxdjango