This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from collections import namedtuple | |
from spidermon import Monitor, MonitorSuite, monitors | |
def check_coverage(expected, current, parent_field=None): | |
CoverageResult = namedtuple("CoverageResult", ("status", "failures")) | |
failures = [] | |
for field, value in expected.items(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from spidermon import Monitor, MonitorSuite | |
from spidermon.core.suites import MonitorSuite | |
from spidermon.runners import TextMonitorRunner | |
from spidermon.core.actions import Action | |
class StandaloneMonitor(Monitor): | |
def test_number_of_errors(self): | |
num_errors = self.data["num_errors"] | |
self.assertLessEqual(num_errors, 10, msg="Many errors!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ics import Calendar | |
from telegram.ext import Updater, CommandHandler | |
def ics_calendar(): | |
with open("lhc.ics", "r") as f: | |
calendar = Calendar(f.read()) | |
return calendar | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import itertools | |
import json | |
from urllib.parse import urljoin | |
import requests | |
from ics import Calendar, Event | |
from parsel import Selector | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import os | |
from scrapy import signals | |
from scrapy.exceptions import NotConfigured | |
from scrapy.utils.project import data_path | |
def json_serial(obj): | |
"""JSON serializer for objects not serializable by default json code""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def recursive_flatten(nested): | |
"""Return a flatten array from an arbitrarily nested array of integers | |
This function is recursive so it could not be used with lists with high | |
levels of nesting to avoid recursion errors | |
>>> recursive_flatten([]) | |
[] | |
>>> recursive_flatten([1, 2, 3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import re | |
import urllib2 | |
def today_packtpub_free_ebook(): | |
FREE_EBOOK_URL = 'https://www.packtpub.com/packt/offers/free-learning' | |
try: | |
request = urllib2.Request(FREE_EBOOK_URL) | |
response = urllib2.urlopen(request) | |
except: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import os | |
import re | |
import socket | |
import Tkinter as Tk | |
import urllib2 | |
import webbrowser | |
FREE_EBOOK_URL = 'https://www.packtpub.com/packt/offers/free-learning' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/env/python | |
import re | |
import sys | |
def read_credit_card_data(purchases_file, year, tags=None): | |
with open(purchases_file, 'r') as purchases_data: | |
purchases = purchases_data.readlines() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from datetime import datetime | |
from icalendar import Calendar, Event | |
import json | |
import os | |
import urllib2 | |
if __name__ == '__main__': | |
LHC_ICS_FILE = '/home/hscps/hsc.tia.mat.br/lhc.ics' |
NewerOlder