<commit_before>#!/usr/bin/python

import re
import urllib.request
from datetime import date

try:
    from czml import czml
except ImportError:
    import czml

class EclipseTrack:

    _properties = ('date', 'columns', 'url',
                   'time', 'position', 'ms_diam_ratio',
                   'sun_altitude', 'sun_azimuth',
                   'path_width', 'central_line_duration')

    # Start by taking a raw data string and parsing it build the waypoints list
    def __init__(self, date):

        self.date = date
        self.url = None
        self.html = None
        self.columns = [ 'Time','NorthLimitLat', 'NorthLimitLon', 'SouthLimitLat', 'SouthLimitLon', 'CentralLat', 'CentralLon',
                         'MSDiamRatio', 'SunAltitude', 'SunAzimuth', 'PathWidth', 'CentralLineDuration' ]
        self.time = []
        self.position = { 'north': [], 'south': [], 'central': [] }
        self.ms_diam_ratio = []
        self.sun_altitude = []
        self.sun_azimuth = []
        self.path_width = []
        self.central_line_duration = []

    def loadFromURL(self, url):
        self.url = url
        iso = self.date.isoformat()
        r = urllib.request.urlopen(self.url)
        if r.status != 200:
            raise Exception('Unable to load eclipse event: ' + iso + ' (URL: ' + self.url + ')')
        else:
            html = r.read().decode('utf-8')
            self.loadFromRawHTML(html)

    def loadFromRawHTML(self, rawhtml):
        print(rawhtml)
        p1 = rawhtml.partition('<pre>');
        p2 = p1[2].partition('</pre>');
        html = p2[0].strip()
        if len(html) == 0:
            raise Exception('raw data string not found between <pre> tags')
        else:
            self.parseHTML(html)

    def parseHTML(self, html):
        allrows = html.split('\n')
        limits = 0
        for row in allrows:
            if 'Limits' in row:
                limits += 1
            elif limits == 1:
                row_stripped = row.strip()
                if len(row_stripped) > 0:
                    row_split = self.preparseHyphens(re.split('\s+',row_stripped))<commit_msg>fix build for both python 2.7 and 3.3 (for real)<commit_after>#!/usr/bin/python

import re, sys
from datetime import date

if sys.version[0] is '3':
    import urllib.request
else:
    import urllib


try:
    from czml import czml
except ImportError:
    import czml

class EclipseTrack:

    _properties = ('date', 'columns', 'url',
                   'time', 'position', 'ms_diam_ratio',
                   'sun_altitude', 'sun_azimuth',
                   'path_width', 'central_line_duration')

    # Start by taking a raw data string and parsing it build the waypoints list
    def __init__(self, date):

        self.date = date
        self.url = None
        self.html = None
        self.columns = [ 'Time','NorthLimitLat', 'NorthLimitLon', 'SouthLimitLat', 'SouthLimitLon', 'CentralLat', 'CentralLon',
                         'MSDiamRatio', 'SunAltitude', 'SunAzimuth', 'PathWidth', 'CentralLineDuration' ]
        self.time = []
        self.position = { 'north': [], 'south': [], 'central': [] }
        self.ms_diam_ratio = []
        self.sun_altitude = []
        self.sun_azimuth = []
        self.path_width = []
        self.central_line_duration = []

    def loadFromURL(self, url):
        self.url = url
        iso = self.date.isoformat()
        if sys.version[0] is '3':
            r = urllib.request.urlopen(self.url)
            status = r.status
        else:
            r = urllib.urlopen(self.url)
            status = r.getcode()
        if status != 200:
            raise Exception('Unable to load eclipse event: ' + iso + ' (URL: ' + self.url + ')')
        else:
            html = r.read().decode('utf-8')
            self.loadFromRawHTML(html)

    def loadFromRawHTML(self, rawhtml):
        p1 = rawhtml.partition('<pre>');
        p2 = p1[2].partition('</pre>');
        html = p2[0].strip()
        if len(html) == 0:
            raise Exception('raw data string not found between <pre> tags')
        else:
            self.parseHTML(html)

    def parseHTML(self, html):
        allrows = html.split('\n')
        limits = 0
        for row in allrows:
            if 'Limits' in row:
                limits += 1
            elif limits == 1:
                row_stripped = row.strip()
                if len(row_stripped) > 0:
                    row_split = self.preparseHyphens(re.split('\s+',row_stripped))
{'fraction_non_alphanumeric': 0.13082237575217295, 'fraction_numerical': 0.008468910184978827, 'mean_word_length': 1.9448818897637796, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5194414', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1338, 'n_words': 330}