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
# open textfile | |
filename = 'text.txt' | |
with open(filename, 'rU') as f: | |
lines = f.readlines() | |
newline = f.newlines | |
if not newline: | |
raise IOError, "no newlines in %s, possible no textfile" % filename | |
if isinstance(newline, tuple): | |
raise IOError, "more than one type of newlines in %s" % filename |
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
with io.open(..) as f: | |
# do something | |
pass | |
# save the type of newlines | |
self.newlines = f.newlines |
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
class TextPatcherBase(object): | |
def mangle_doc(self, doc, rflag, mapping): | |
raise NotImplementedError | |
def mangle_docs(self, patchfunc, mappings): | |
self.ndocs_patched = 0 | |
for doc in self.docs: | |
if doc.key in mappings: | |
self.mangle_doc(doc, True, mappings[doc.key]) |
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 collections import Counter | |
class LiveCells(object): | |
def __init__(self): | |
self.cells = set() | |
def add_cell(self, position): | |
self.cells.add(position) | |
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
class Gui(object) | |
def init_remote_control(self): | |
if self.activate_remote_control: | |
self.create_timer() | |
def create_timer(self): | |
self.timer = QTimer() | |
self.timer.timeout.connect(self.update) | |
self.timer.start(1000) |
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 logging | |
# configuration of the default standard logger - log to a file | |
logging.basicConfig(format='%(asctime)s %(message)s', | |
level=logging.DEBUG, | |
filename='logfile.log', | |
datefmt='%d.%m.%Y %H:%M:%S') | |
# we need an additional logger, that will log to the console | |
# use at main or program start |
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
>>> a = '1234aaaa56789bbbbbb0123456789ccccccc1111111dddddddddd' | |
>>> b = 'aa12456bbbb0123cc8cccc111111dddddd567889' | |
>>> import difflib | |
>>> s = difflib.SequenceMatcher(None, a, b) | |
>>> s.get_opcodes() | |
[('insert', 0, 0, 0, 2), ('equal', 0, 2, 2, 4), ('delete', 2, 3, 4, 4), ('equal', 3, 4, 4, 5), ('delete', 4, 8, 5, 5), ('equal', 8, 10, 5, 7), ('delete', 10, 15, 7, 7), ('equal', 15, 23, 7, 15), ('replace', 23, 27, 15, 17), ('equal', 27, 28, 17, 18), ('delete', 28, 29, 18, 18), ('equal', 29, 33, 18, 22), ('delete', 33, 37, 22, 22), ('equal', 37, 49, 22, 34), ('replace', 49, 53, 34, 40)] | |
>>> i = s.get_grouped_opcodes() | |
>>> next(i) | |
[('insert', 0, 0, 0, 2), ('equal', 0, 2, 2, 4), ('delete', 2, 3, 4, 4), ('equal', 3, 4, 4, 5), ('delete', 4, 8, 5, 5), ('equal', 8, 10, 5, 7), ('delete', 10, 15, 7, 7), ('equal', 15, 18, 7, 10)] | |
>>> next(i) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Skizze, wie das Löschen und Entlöschen eines Belegs in etwa funktionieren soll | |
# die Funktion basiert darauf, daß der Inhalt des Feldes "KASSENNAME" in weiteren | |
# Prozeßschritten definitiv nie benötigt wird | |
# außerdem wird das Image in der IBF-Datei nicht wirklich gelöscht, sondern erhält | |
# nur eine andere PIC-Nummer, die es so definitiv auch nie geben kann. Somit ist | |
# ein Entlöschen sowohl des Belegs als auch des Images problemlos möglich. Durch | |
# das Ändern der PIC-Nummer ist sichergestellt, daß das Image in nachfolgenden | |
# Prozessen wirklich nicht gefunden werden kann | |
class CDB_Form(object): | |
def delete(self): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer