code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
# http://msdn.microsoft.com/XML/rss/sle/default.aspx
from base import validatorBase
from validators import eater, text
class sort(validatorBase):
def getExpectedAttrNames(self):
return [(None,u'data-type'),(None,u'default'),(None,u'element'),(None, u'label'),(None,u'ns')]
class group(validatorBase):
def ge... | Python |
"""$Id: rss.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from logging import *
from validators impor... | Python |
"""$Id: textInput.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from validators import *
from extension import extension_everywhere
... | Python |
"""$Id: link.py 1060 2010-01-23 01:29:14Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1060 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
#
# Atom link ... | Python |
"""$Id: channel.py 1033 2008-11-18 11:35:34Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1033 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from logging import *
from validators... | Python |
"""
$Id: mediaTypes.py 988 2008-03-12 18:22:48Z sa3ruby $
This module deals with valid internet media types for feeds.
"""
__author__ = "Joseph Walton <http://www.kafsemo.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2004 Joseph Walton"
from cgi import parse_header
from logging import *
FEED... | Python |
"""$Id: category.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
#
# author e... | Python |
from validators import *
from logging import *
import re
class OpenSearchDescription(validatorBase):
def __init__(self):
self.exampleFound = 0
validatorBase.__init__(self)
def validate(self):
name=self.name.replace("opensearch_",'')
if not "ShortName" in self.children:
self.log(MissingElemen... | Python |
#!/usr/bin/python
"""
$Id$
This module deals with detecting XML encodings, using both BOMs and
explicit declarations.
"""
__author__ = "Joseph Walton <http://www.kafsemo.org/>"
__version__ = "$Revision$"
__copyright__ = "Copyright (c) 2004 Joseph Walton"
import codecs
import re
from logging import ObscureEncoding, N... | Python |
"""$Id: generator.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
#
# Atom ge... | Python |
"""$Id: skipHours.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import text
from logg... | Python |
"""$Id: opml.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
from logging impo... | Python |
"""$Id: skipDays.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import text
from loggi... | Python |
"""$Id: text_plain.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
"""Output class for plain text output"""
from base import BaseForm... | Python |
"""$Id: text_html.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
"""Output class for HTML text output"""
from base import BaseFormat... | Python |
"""$Id: application_test.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
"""Output class for testing that all output messages are defi... | Python |
"""$Id: text_xml.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
"""Output class for xml output"""
from base import BaseFormatter
fro... | Python |
"""$Id: base.py 1055 2009-05-19 15:12:42Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1055 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
"""Base class for output classes"""
from UserList import UserList
impo... | Python |
"""$Id: __init__.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
__all__ = ['base', 'text_plain', 'text_html']
| Python |
#!/usr/bin/python
"""
$Id: xmlEncoding.py 988 2008-03-12 18:22:48Z sa3ruby $
This module deals with detecting XML encodings, using both BOMs and
explicit declarations.
"""
__author__ = "Joseph Walton <http://www.kafsemo.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2004 Joseph Walton"
import... | Python |
"""$Id: entry.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
from logging imp... | Python |
"""$Id: feed.py 1040 2009-02-15 20:01:32Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1040 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
from logging im... | Python |
"""$Id: kml.py 1057 2009-07-21 21:54:14Z sa3ruby $"""
__author__ = "Gregor J. Rothfuss <http://greg.abstrakt.ch/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1057 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
import... | Python |
"""$Id: validators.py 1058 2009-08-22 09:35:18Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1058 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from logging import *
import re, t... | Python |
#$Id
####
# Copyright 2000,2001 by Timothy O'Malley <timo@alum.mit.edu>
#
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software
# and its documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appear in all
# copies... | Python |
"""$Id: base.py 1049 2009-05-06 02:00:03Z rothfuss $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1049 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from xml.sax.handler import ContentHandler
from xml.sax.xmlreader impo... | Python |
"""$Id: content.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase, namespaces
from validators import *
fr... | Python |
"""$Id: extension.py 1061 2010-01-25 17:50:01Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net>, Mark Pilgrim <http://diveintomark.org/> and Phil Ringnalda <http://philringnalda.com>"
__version__ = "$Revision: 1061 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby, Mark Pilgrim and Phil Ringnalda"
... | Python |
"""$Id: __init__.py 1027 2008-09-26 14:41:21Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1027 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
import socket
if hasattr(socket, 'setdefaulttimeout'):
socket.set... | Python |
"""$Id: en.py 1041 2009-02-18 00:19:04Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 1041 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
import feedvalidator
from feedvalidator.logging import *
line = "line %(... | Python |
"""$Id: __init__.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
| Python |
from base import validatorBase
from validators import *
from extension import extension_everywhere
class service(validatorBase, extension_everywhere):
def getExpectedAttrNames(self):
return [] # (None,u'scheme'),(None,u'fixed')]
def validate(self):
if not "app_workspace" in self.children:
self.log(M... | Python |
"""$Id: author.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
#
# author ele... | Python |
"""$Id: image.py 988 2008-03-12 18:22:48Z sa3ruby $"""
__author__ = "Sam Ruby <http://intertwingly.net/> and Mark Pilgrim <http://diveintomark.org/>"
__version__ = "$Revision: 988 $"
__copyright__ = "Copyright (c) 2002 Sam Ruby and Mark Pilgrim"
from base import validatorBase
from validators import *
from extension i... | Python |
from validators import *
class media_elements:
def do_media_adult(self):
self.log(DeprecatedMediaAdult({"parent":self.name, "element":"media:adult"}))
return truefalse(), noduplicates()
def do_media_category(self):
return media_category()
def do_media_copyright(self):
return media_copyright(), no... | Python |
"""MIME-Type Parser
This module provides basic functions for handling mime-types. It can handle
matching mime-types against a list of media-ranges. See section 14.1 of the
HTTP specification [RFC 2616] for a complete explanation.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
Contents:
- parse_mi... | Python |
# -*- coding: utf-8 -*-
#old way
from distutils.core import setup
#new way
#from setuptools import setup, find_packages
setup(name='mimeparse',
version='0.1.4',
description='A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.',
long_desc... | Python |
"""
Python tests for Mime-Type Parser.
This module loads a json file and converts the tests specified therein to a set
of PyUnitTestCases. Then it uses PyUnit to run them and report their status.
"""
__version__ = "0.1"
__author__ = 'Ade Oshineye'
__email__ = "ade@oshineye.com"
__credits__ = ""
import mimeparse
impor... | Python |
from urllib import urlencode
import atompubbase
import atompubbase.events
from atompubbase.model import init_event_handlers
init_event_handlers()
def apply_credentials_file(filename, http, error):
parts = file(filename, "r").read().splitlines()
if len(parts) == 2:
name, password = parts
http.add_c... | Python |
# Copyright Google 2007
"""
An eventing system for atompubbase objects.
Each class that is registered with add_event_handlers()
will be hooked into the event system. Clients can then
register for callbacks when a member function is called,
filtering on when to trigger the callback. There
are several axes that can be us... | Python |
#!/usr/bin/env python
import glob, unittest, os, sys
from trace import fullmodname
try:
from tests.utils import cleanup
except:
def cleanup():
pass
# try to start in a consistent, predictable location
if sys.path[0]:
os.chdir(sys.path[0])
# find all of the planet test modules
modules = map(fullm... | Python |
"""MIME-Type Parser
This module provides basic functions for handling mime-types. It can handle
matching mime-types against a list of media-ranges. See section 14.1 of the
HTTP specification [RFC 2616] for a complete explanation.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
Contents:
- parse_mi... | Python |
# -*- coding: utf-8 -*-
#old way
from distutils.core import setup
#new way
#from setuptools import setup, find_packages
setup(name='mimeparse',
version='0.1.4',
description='A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.',
long_desc... | Python |
"""
Python tests for Mime-Type Parser.
This module loads a json file and converts the tests specified therein to a set
of PyUnitTestCases. Then it uses PyUnit to run them and report their status.
"""
__version__ = "0.1"
__author__ = 'Ade Oshineye'
__email__ = "ade@oshineye.com"
__credits__ = ""
import mimeparse
impor... | Python |
"""
There are four classes that make up the core
of the atompub model.
class Context
class Service
class Collection
class Entry
Context represents the current state, as represented
by a service document, a collection and an entry.
Each atompub object (Service, Collection, or Entry)
is just instantiated with a URI (... | Python |
SERVICE1 = """<?xml version="1.0" encoding='utf-8'?>
<service xmlns="http://www.w3.org/2007/app">
<workspace title="Main Site" >
<collection
title="My Blog Entries"
href="http://example.org/reilly/main" />
<collection
title="Pictures"
href="http://example.org/reilly/pic" >
<... | Python |
from pretty import pretty
try:
from xml.etree.ElementTree import fromstring, tostring
except:
from elementtree.ElementTree import fromstring, tostring
src = """<html:div xmlns:html="http://www.w3.org/1999/xhtml">
<html:p >I took a couple of days off work
and we drove down to Florida to visit family in "The... | Python |
#!/usr/bin/env python
import glob, unittest, os, sys
from trace import fullmodname
try:
from tests.utils import cleanup
except:
def cleanup():
pass
# try to start in a consistent, predictable location
if sys.path[0]:
os.chdir(sys.path[0])
# find all of the planet test modules
modules = map(fullm... | Python |
from model import init_event_handlers, Context, Service, Collection, Entry, ATOM, XHTML
from httplib2 import Http
import unittest
import events
try:
from xml.etree.ElementTree import fromstring, tostring
except:
from elementtree.ElementTree import fromstring, tostring
ATOM_CONTENT = "{%s}content/{%s}div" % (A... | Python |
try:
from xml.etree.ElementTree import fromstring, tostring, SubElement
import xml.etree.ElementTree as ElementTree
except:
from elementtree.ElementTree import fromstring, tostring, SubElement
import elementtree.ElementTree as ElementTree
class namespace(object):
def __init__(self, uri):
se... | Python |
import urlparse
import urllib
import httplib2
from email import message_from_string, message_from_file
import os
class MockHttp:
"""
A mock for httplib2.Http that takes its
response headers and bodies from files on disk
"""
def __init__(self, directory):
self.directory = directory
... | Python |
"""
iri2uri
Converts an IRI to a URI.
"""
__author__ = "Joe Gregorio (joe@bitworking.org)"
__copyright__ = "Copyright 2006, Joe Gregorio"
__contributors__ = []
__version__ = "1.0.0"
__license__ = "MIT"
__history__ = """
"""
import urlparse
# Convert an IRI to a URI following the rules in RFC 3987
#
# The characte... | Python |
from __future__ import generators
"""
httplib2
A caching http interface that supports ETags and gzip
to conserve bandwidth.
Requires Python 2.3 or later
Changelog:
2007-08-18, Rick: Modified so it's able to use a socks proxy if needed.
"""
__author__ = "Joe Gregorio (joe@bitworking.org)"
__copyright__ = "Copyrigh... | Python |
__author__ = "Joe Gregorio <http://bitworking.org/>"
__version__ = "$Revision: 150 $"
__copyright__ = "Copyright (c) 2006 Joe Gregorio"
__license__ = "MIT"
import os
import sys
import httplib2
try:
from xml.etree.ElementTree import fromstring, tostring, SubElement
except:
from elementtree.ElementTree impo... | Python |
#!/usr/bin/python2.6
#
# Simple http server to emulate api.playfoursquare.com
import logging
import shutil
import sys
import urlparse
import SimpleHTTPServer
import BaseHTTPServer
class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""Handle playfoursquare.com requests, for testing."""
def do_GET(self... | Python |
#!/usr/bin/python
import os
import subprocess
import sys
BASEDIR = '../main/src/com/joelapenna/foursquare'
TYPESDIR = '../captures/types/v1'
captures = sys.argv[1:]
if not captures:
captures = os.listdir(TYPESDIR)
for f in captures:
basename = f.split('.')[0]
javaname = ''.join([c.capitalize() for c in basena... | Python |
#!/usr/bin/python
"""
Pull a oAuth protected page from foursquare.
Expects ~/.oget to contain (one on each line):
CONSUMER_KEY
CONSUMER_KEY_SECRET
USERNAME
PASSWORD
Don't forget to chmod 600 the file!
"""
import httplib
import os
import re
import sys
import urllib
import urllib2
import urlparse
import user
from xml.... | Python |
#!/usr/bin/python
import datetime
import sys
import textwrap
import common
from xml.dom import pulldom
PARSER = """\
/**
* Copyright 2009 Joe LaPenna
*/
package com.joelapenna.foursquare.parsers;
import com.joelapenna.foursquare.Foursquare;
import com.joelapenna.foursquare.error.FoursquareError;
import com.joel... | Python |
#!/usr/bin/python
import logging
from xml.dom import minidom
from xml.dom import pulldom
BOOLEAN = "boolean"
STRING = "String"
GROUP = "Group"
# Interfaces that all FoursquareTypes implement.
DEFAULT_INTERFACES = ['FoursquareType']
# Interfaces that specific FoursqureTypes implement.
INTERFACES = {
}
DEFAULT_CLA... | Python |
# -*- coding: UTF-8 -*-
import os, sys
tmp_dir = sys.argv[0].split('/')
home_dir = ''
for i in range(len(tmp_dir) - 1):
home_dir = home_dir + tmp_dir[i] + '/'
#update keywordlist
os.system('python %slist/make_kwl.py' % (home_dir))
#api
os.system('python %spy/meituan.py' % (home_dir))
os.system('python %spy/aiban... | Python |
import sys
tmp_dir = sys.argv[0].split('/')
home_dir = ''
for i in range(len(tmp_dir) - 1):
home_dir = home_dir + tmp_dir[i] + '/'
fin = open('%s/keyword' % (home_dir), 'r')
fout = open('%s/keywordlist' % (home_dir), 'w')
fout.write('{\n')
flag = 0
while 1 + 1 == 2:
l = fin.readline().replace('\r', '').repla... | Python |
# -*- coding: UTF-8 -*-
from xml.etree import ElementTree as ET
import urllib2
from deal_info_api import *
def deal_city(tuan, city):
(f_id, d_id, orig) = judge_begin(tuan, city)
f_url = urllib2.urlopen('http://www.meituan.com/api/v1/%s/deals' % (city))
root_url = ET.fromstring(f_url.read())
f_... | Python |
"""Beautiful Soup
Elixir and Tonic
"The Screen-Scraper's Friend"
http://www.crummy.com/software/BeautifulSoup/
Beautiful Soup parses a (possibly invalid) XML or HTML document into a
tree representation. It provides methods and Pythonic idioms that make
it easy to navigate, search, and modify the tree.
A well-formed X... | Python |
# -*- coding: UTF-8 -*-
from xml.etree import ElementTree as ET
import os, sys
def get_home_dir():
tmp_dir = sys.argv[0].split('/')
home_dir = ''
for i in range(len(tmp_dir) - 2):
home_dir = home_dir + tmp_dir[i] + '/'
return home_dir
def deal_info_add(f_xml, subdeal, li_from, li_to, tabsum):
su... | Python |
# -*- coding: UTF-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib2
from deal_info_web import *
def deal_city(tuan, city, city_id):
(f_id, d_id, orig) = judge_begin(tuan, city)
f_url = urllib2.urlopen('http://www.55tuan.com/?c=%s' % (city_id))
soup = BeautifulSoup(f_url.read())
f_xml = o... | Python |
# -*- coding: UTF-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib2
from deal_info_web import *
def deal_city(tuan, city, ename):
(f_id, d_id, orig) = judge_begin(tuan, city)
f_url = urllib2.urlopen('http://www.24quan.com/city.php?ename=%s&r=' % (ename))
soup = BeautifulSoup(f_url.read())
... | Python |
# -*- coding: UTF-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib2
from deal_info_web import *
def deal_city(tuan, city):
(f_id, d_id, orig) = judge_begin(tuan, city)
f_url = urllib2.urlopen('http://www.nuomi.com/%s' % (city))
soup = BeautifulSoup(f_url.read())
f_xml = open('%sxml/%s_%s... | Python |
# -*- coding: UTF-8 -*-
from xml.etree import ElementTree as ET
import urllib2
from deal_info_api import *
def deal_info_time(f_xml, subdeal, li_from, li_to, tabsum, hms):
subdeal_li = subdeal.getiterator(li_from)
zt = subdeal_li[0].text
year = zt.split('年'.decode('utf-8'))
month = year[1].split('... | Python |
# -*- coding: UTF-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib2
from deal_info_web import *
def deal_city(tuan, city):
(f_id, d_id, orig) = judge_begin(tuan, city)
f_url = urllib2.urlopen('http://www.zhaozhe.com/%s/index.html' % (city))
soup = BeautifulSoup(f_url.read())
f_xml = open... | Python |
# -*- coding: UTF-8 -*-
from xml.etree import ElementTree as ET
import os, time
from deal_info_api import get_home_dir, deal_info_source, judge_begin, judge_end
def deal_info_add(f_xml, li, text, tabsum):
f_xml.write(('\t' * tabsum + '<%s>%s</%s>\n' % (li, text, li)).encode('utf-8'))
def deal_info_source(f_xml, ... | Python |
# -*- coding: UTF-8 -*-
from xml.etree import ElementTree as ET
import urllib2, time
from deal_info_api import *
def deal_info_time(f_xml, deal, li_from, li_to, tabsum):
ut = time.gmtime(time.time() + 28800)
t = '%Y-%m-%d %X'
f_xml.write(('\t' * tabsum + '<start_time>%s+0800</start_time>\n' % (time.strf... | Python |
# -*- coding: UTF-8 -*-
from xml.etree import ElementTree as ET
import urllib2
from deal_info_api import *
def deal_info_url(f_xml, deal, url):
deal_url = deal.getiterator(url)
for node in deal_url:
f_xml.write(('\t' * 2 + '<url><![CDATA[%s]]></url>\n' % (node.text)).encode('utf-8'))
def deal_city(tuan, cit... | Python |
# -*- coding: UTF-8 -*-
from xml.etree import ElementTree as ET
import urllib2
from deal_info_api import *
def deal_info_id(f_xml, deal, city):
deal_id = deal.getiterator('id')
if str(deal_id[0].text) == 'None':
f_xml.close()
os.system('rm %sxml/aibang_%s.xml' % (get_home_dir(), city))
return 1
for nod... | Python |
# -*- coding: UTF-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib2
from deal_info_web import *
def deal_city(tuan, city):
(f_id, d_id, orig) = judge_begin(tuan, city)
f_url = urllib2.urlopen('http://www.manzuo.com/%s/index.htm' % (city))
soup = BeautifulSoup(f_url.read())
f_xml = open('... | Python |
# -*- coding: UTF-8 -*-
from xml.etree import ElementTree as ET
import os, urllib2, time
from deal_info_api import *
def deal_info_time(f_xml, subdeal, li_from, li_to, tabsum):
subdeal_li = subdeal.getiterator(li_from)
ut = time.gmtime(int(subdeal_li[0].text) + 28800)
t = '%Y-%m-%d %X'
f_xml.write(... | Python |
# -*- coding: UTF-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib2
from deal_info_web import *
def deal_city(tuan, city):
(f_id, d_id, orig) = judge_begin(tuan, city)
f_url = urllib2.urlopen('http://tuan.qq.com/%s/' % (city))
soup = BeautifulSoup(f_url.read())
f_xml = open('%sxml/%s_%s.... | Python |
#!/usr/bin/env python
import time
t = time.time()
u = time.gmtime(t)
s = time.strftime('%a, %e %b %Y %T GMT', u)
print 'Content-Type: text/javascript'
print 'Cache-Control: no-cache'
print 'Date: ' + s
print 'Expires: ' + s
print ''
print 'var timeskew = new Date().getTime() - ' + str(t*1000) + ';'
| Python |
'''
Created on 21-03-2011
@author: maciek
'''
from formater import formatString
import os
class IndexGenerator(object):
'''
Generates Index.html for iOS app OTA distribution
'''
basePath = os.path.dirname(__file__)
templateFile = os.path.join(basePath,"templates/index.tmpl")
releaseUrls = ""
... | Python |
'''
Created on 21-03-2011
@author: maciek
'''
def formatString(format, **kwargs):
'''
'''
if not format: return ''
for arg in kwargs.keys():
format = format.replace("{" + arg + "}", "##" + arg + "##")
format = format.replace ("{", "{{")
format = format.replace("}", "}}")
for... | Python |
'''
Created on 21-03-2011
@author: maciek
'''
from IndexGenerator import IndexGenerator
from optparse import OptionParser
import os
import tempfile
import shutil
import logging
logging.basicConfig(level = logging.DEBUG)
parser = OptionParser()
parser.add_option('-n', '--app-name', action='store', dest='appName', hel... | Python |
"""Will attempt to get a lock, and quit if unavailable.
Adapted from http://code.activestate.com/recipes/576572/"""
import contextlib, errno, os, sys
@contextlib.contextmanager
def flock(path):
try:
fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR)
except OSError, e:
if e.errno != errno.E... | Python |
from django.core.management import setup_environ
import settings
setup_environ(settings)
from server.feedme.models import *
import datetime
import sys
import numpy
import nltk
import time
from django.core.mail import EmailMultiAlternatives
from django.utils import html
from django.contrib.auth.models import User
from d... | Python |
import smtpd
import asyncore
server = smtpd.DebuggingServer(('127.0.0.1', 1025), None)
asyncore.loop()
| Python |
from __future__ import with_statement
from django.core.management import setup_environ
import settings
setup_environ(settings)
from django.contrib.auth.models import User
from server.feedme.models import *
from django.db import transaction
import math
import datetime
import sys, codecs, traceback
from flock import fl... | Python |
"""Disk And Execution MONitor (Daemon)
Configurable daemon behaviors:
1.) The current working directory set to the "/" directory.
2.) The current file creation mode mask set to 0.
3.) Close all open files (1024).
4.) Redirect standard I/O streams to "/dev/null".
A failed call to fork() now raises an exc... | Python |
from django.core.management import setup_environ
import settings
setup_environ(settings)
from django.contrib.auth.models import User
from server.feedme.models import *
import urllib
import feedparser
from django.utils import simplejson
import operator
from feedme.recommend import *
import datetime
from django.core.mail... | Python |
# encoding: utf-8
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth import authenticate
try:
# If you have django-registration installed, this is a form you can
# use for users that signup.
from registration.forms import RegistrationFormUniqueEmail
... | Python |
# encoding: utf-8
from django.conf import settings
from django.contrib.auth.models import User
from django import forms
dummy_field = forms.EmailField()
def is_email(username):
try:
dummy_field.clean(username)
return True
except forms.ValidationError:
return False
# This is an authent... | Python |
from django.conf.urls.defaults import *
urlpatterns = patterns('email_usernames.views',
url(r'^login/$', 'email_login', name="email-login"),
)
try:
from registration.views import register
from email_usernames.forms import EmailRegistrationForm
urlpatterns += patterns('',
url(r'^register/$', ... | Python |
from django.conf import settings
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth import login
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from email_usernames.forms import EmailLoginForm
def email_login(r... | Python |
from django.db.models.signals import post_syncdb
message = """
'django-email-accounts' has detected that you just installed Django's authentication system (django.auth).
For your convenience, django-email-accounts can alter the user table's username field to allow 75 characters instead
of the de... | Python |
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ... | Python |
import os
DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' ... | Python |
from django.http import HttpResponse
from django.contrib.auth.models import User
from models import *
from django.contrib.auth.decorators import login_required
import datetime
from server.feedme.models import *
def start_email_daemon():
"""Creates a daemon to send emails every 20 seconds. Uses daemon.py
to fo... | Python |
from django.shortcuts import render_to_response
from models import *
import codecs, sys
import versionutils
# set stdout to Unicode so we can write Unicode strings to stdout
# todo: create some sort of startup script which calls this
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
def homepage(request):
return ... | Python |
from django.http import HttpResponse
from django.utils import simplejson
from django.contrib.auth.models import User
from models import *
from django.contrib.auth.decorators import login_required
from django.db import IntegrityError
from django.db import transaction
from django.forms.fields import email_re
import math... | Python |
from django.shortcuts import render_to_response
def bookmarklet_install(request):
return render_to_response('bookmarklet_install.html')
| Python |
from django.utils import simplejson
import urllib2
def latest_url():
response = urllib2.urlopen('http://groups.csail.mit.edu/haystack/feedme/current_version.js')
html = response.read()
html = html.replace("versionData = ", "")
version = simplejson.loads(html)
return version['url']
| Python |
from django.http import HttpResponse
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from html5lib import treebuilders
from BeautifulSoup import BeautifulSoup
import nltk
import re
import html5lib
import versio... | Python |
from django.http import HttpResponse
from django.utils import simplejson
from django.contrib.auth.models import User
from models import *
from django.contrib.auth.decorators import login_required
def address_book(request):
if request.user.is_authenticated:
receivers = Receiver.objects.filter(
sha... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.