fixed some bugs in gtk 3.18 and added some experimental stuff that DOES NOT WORK YET!

gh-pages
Wolf Vollprecht 2016-02-05 23:52:43 +01:00
parent 9358bf8e90
commit f02b5af858
32 changed files with 5171 additions and 42 deletions

View File

@ -16,6 +16,7 @@
bind "<ctl>p" { "toggle-preview" () };
bind "<ctl>w" { "close-window" () };
bind "<ctl>f" { "toggle-search" () };
bind "<ctl><shift>b" { "toggle-bibtex" () };
bind "<ctl><shift>r" { "toggle-search-replace" () };
bind "<ctl><shift>f" { "toggle-search-replace" () };
bind "F11" { "toggle-fullscreen" () };
@ -42,15 +43,17 @@
}
#UberwriterWindow.small .uberwriter-editor {
font: Inconsolata 12;
font: Fira Mono 10;
}
#UberwriterWindow.medium .uberwriter-editor {
font: Inconsolata 15;
font: Fira Mono 15;
}
#UberwriterWindow.large .uberwriter-editor {
font: Inconsolata 17;
/*font: Inconsolata 17;
*/
font: Fira Mono 12;
}
#UberwriterWindow GtkAlignment {
@ -58,6 +61,10 @@
margin-bottom: 60px;
}
#titlebar_revealer {
padding: 0;
}
#UberwriterWindow.dark_mode {
background: #333;
}
@ -65,7 +72,6 @@
#UberwriterWindow.dark_mode .uberwriter-editor {
color: #CCC;
background: @dark_bg;
-GtkWidget-cursor-color: shade(#4D9FCE, 0.9);
}
@ -178,7 +184,7 @@
}
#LexikonBubble {
font: serif 12;
font: serif 10;
background: #FFF;
border-radius: 4px;
margin: 5px;

View File

View File

@ -24,6 +24,7 @@ import subprocess
import tempfile
import threading
from pprint import pprint
from gi.repository import Gtk, Gdk, GdkPixbuf, GObject
from uberwriter_lib import LatexToPNG
@ -48,12 +49,20 @@ GObject.threads_init() # Still needed?
import telnetlib
import subprocess
class DictAccessor(object):
def __init__( self, host='localhost', port=2628, timeout=60 ):
def __init__( self, host='pan.alephnull.com', port=2628, timeout=60 ):
self.tn = telnetlib.Telnet( host, port )
self.timeout = timeout
self.login_response = self.tn.expect( [ self.reEndResponse ], self.timeout )[ 2 ]
bytes
def getOnline(self, word):
p = subprocess.Popen(['dict', '-d', 'wn', word], stdout=subprocess.PIPE)
return p.communicate()[0]
def runCommand( self, cmd ):
self.tn.write( cmd.encode('utf-8') + b'\r\n' )
return self.tn.expect( [ self.reEndResponse ], self.timeout )[ 2 ]
@ -89,12 +98,16 @@ class DictAccessor(object):
d = database
w = word.replace( '"', r'\"' )
dsplit = self.runCommand( 'DEFINE %s "%s"' % ( d, w ) ).splitlines( True )
# dsplit = self.getOnline(word).splitlines()
dlist = list( )
if dsplit[ -1 ].startswith( b'250 ok' ) and dsplit[ 0 ].startswith( b'1' ):
dlines = dsplit[ 1:-1 ]
dtext = b''.join( dlines )
dlist = self.reDefinition.findall( dtext )
#dlist = [ dtext ]
# print(dlist)
dlist = [ dtext ]
# dlist = dsplit # not using the localhost telnet connection
return dlist
def close( self ):
@ -112,12 +125,12 @@ class DictAccessor(object):
lines = re.sub('\s+', ' ', lines).strip()
lines = re.split(r'( adv | adj | n | v |^adv |^adj |^n |^v )', lines)
res = []
act_res = {}
act_res = {'defs': [], 'class': 'none', 'num': 'None'}
for l in lines:
l = l.strip()
if len(l) == 0:
continue
if l in ['adv', 'adj','n','v']:
if l in ['adv', 'adj', 'n', 'v']:
if act_res:
res.append(act_res.copy())
act_res = {}
@ -154,6 +167,7 @@ class DictAccessor(object):
if act_def and 'description' in act_def:
act_res['defs'].append(act_def.copy())
pprint(act_res)
res.append(act_res.copy())
return res
@ -261,41 +275,45 @@ class UberwriterInlinePreview():
self.popover = None
def open_popover_with_widget(self, widget):
# a = self.TextBuffer.create_child_anchor(self.TextBuffer.get_iter_at_mark(self.ClickMark))
a = Gtk.Window.new(Gtk.WindowType.POPUP)
a.set_transient_for(self.TextView.get_toplevel())
a.grab_focus()
a.set_name("QuickPreviewPopup")
# a.set_attached_to(self.TextView)
a.move(300, 300)
a.set_modal(True)
def close(widget, event, *args):
if(event.keyval == Gdk.KEY_Escape):
widget.destroy()
a.connect('key-press-event', close)
a = self.TextBuffer.create_child_anchor(self.TextBuffer.get_iter_at_mark(self.ClickMark))
lbl = Gtk.Label('')
self.TextView.add_child_at_anchor(lbl, a)
lbl.show()
# a = Gtk.Window.new(Gtk.WindowType.POPUP)
# a.set_transient_for(self.TextView.get_toplevel())
# a.grab_focus()
# a.set_name("QuickPreviewPopup")
# # a.set_attached_to(self.TextView)
# a.move(300, 300)
# a.set_modal(True)
# def close(widget, event, *args):
# if(event.keyval == Gdk.KEY_Escape):
# widget.destroy()
# a.connect('key-press-event', close)
b = Gtk.Grid.new()
alignment = Gtk.Alignment()
alignment.props.margin_bottom = 5
alignment.props.margin_top = 5
alignment.props.margin_left = 4
alignment.add(widget)
a.add(alignment)
# self.TextView.add_child_in_window(b, Gtk.TextWindowType.WIDGET, 200, 200)
# b.attach(Gtk.Label.new("test 123"), 0, 0, 1, 1)
# b.show_all()
a.show_all()
# self.popover = Gtk.Popover.new(b)
# dismiss, rect = popover.get_pointing_to()
# rect.y = rect.y - 20
# popover.set_pointing_to(rect)
# a.show_all()
self.popover = Gtk.Popover.new(lbl)
self.popover.add(alignment)
# a.add(alignment)
dismiss, rect = self.popover.get_pointing_to()
rect.y = rect.y - 20
self.popover.set_pointing_to(rect)
# widget = Gtk.Label.new("testasds a;12j3 21 lk3j213")
# widget.show_all()
widget.show_all()
# b.attach(widget, 0, 1, 1, 1)
# self.popover.set_modal(False)
# self.popover.show_all()
# print(self.popover)
# popover.set_property('width-request', 50)
self.popover.set_modal(True)
self.popover.show_all()
print(self.popover)
self.popover.set_property('width-request', 50)
def click_move_button(self, widget, event):
if event.button == 3:

View File

@ -61,7 +61,7 @@ from uberwriter_lib import Window
from uberwriter_lib import helpers
from .AboutUberwriterDialog import AboutUberwriterDialog
from .UberwriterAdvancedExportDialog import UberwriterAdvancedExportDialog
from .plugins.bibtex import BibTex
# Some Globals
# TODO move them somewhere for better
# accesibility from other files
@ -79,6 +79,7 @@ class UberwriterWindow(Window):
'save-file-as': (GObject.SIGNAL_ACTION, None, ()),
'new-file': (GObject.SIGNAL_ACTION, None, ()),
'toggle-focusmode': (GObject.SIGNAL_ACTION, None, ()),
'toggle-bibtex': (GObject.SIGNAL_ACTION, None, ()),
'toggle-fullscreen': (GObject.SIGNAL_ACTION, None, ()),
'toggle-spellcheck': (GObject.SIGNAL_ACTION, None, ()),
'toggle-preview': (GObject.SIGNAL_ACTION, None, ()),
@ -865,8 +866,8 @@ class UberwriterWindow(Window):
self.update_line_and_char_count()
def override_headerbar_background(self, widget, cr):
# Not needed in Gtk 3.18 anymore apparentlys
if(widget.get_window().get_state() & self.testbits):
bg_color = self.get_style_context().get_background_color(Gtk.StateFlags.ACTIVE)
alloc = widget.get_allocation()
@ -901,7 +902,10 @@ class UberwriterWindow(Window):
cr.fill()
def use_experimental_features(self, val):
self.auto_correct = UberwriterAutoCorrect(self.TextEditor, self.TextBuffer)
try:
self.auto_correct = UberwriterAutoCorrect(self.TextEditor, self.TextBuffer)
except:
logger.debug("Couldn't install autocorrect.")
def finish_initializing(self, builder): # pylint: disable=E1002
@ -933,7 +937,7 @@ class UberwriterWindow(Window):
self.use_headerbar = True
if self.use_headerbar == True:
self.hb_revealer = Gtk.Revealer()
self.hb_revealer = Gtk.Revealer(name='titlebar_revealer')
self.hb = Gtk.HeaderBar()
self.hb_revealer.add(self.hb)
self.hb_revealer.props.transition_duration = 1000
@ -956,7 +960,7 @@ class UberwriterWindow(Window):
self.hb.pack_start(bbtn)
self.hb.pack_end(btn_settings)
self.hb.show_all()
self.testbits = Gdk.WindowState.TILED | Gdk.WindowState.MAXIMIZED
self.testbits = Gdk.WindowState.MAXIMIZED
self.connect('draw', self.override_headerbar_background)
self.title_end = " UberWriter"
@ -1145,11 +1149,13 @@ class UberwriterWindow(Window):
self.gtk_settings = Gtk.Settings.get_default()
self.load_settings(builder)
self.connect_after('realize', self.color_window)
self.plugins = [BibTex(self)]
def color_window(self, widget, data=None):
window_gdk = self.get_window()
window_gdk.set_background(Gdk.Color(0, 1, 0))
# self.connect_after('realize', self.color_window)
# def color_window(self, widget, data=None):
# window_gdk = self.get_window()
# window_gdk.set_background(Gdk.Color(0, 1, 0))
def alt_mod(self, widget, event, data=None):
# TODO: Click and open when alt is pressed

View File

@ -0,0 +1 @@
from .bibtex import BibTex

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkWindow" id="bibtex_window">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="gravity">center</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="searchentry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="activate_on_single_click">False</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkWindow" id="bibtex_window">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="gravity">center</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="searchentry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="activate_on_single_click">False</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<template class="item_template" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="title_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">This is the title</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="author_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
<property name="lines">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="other_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</template>
</interface>

View File

@ -0,0 +1,75 @@
from gi.repository import Gtk, Gio
from . import bibtexparser
from . import fuzzywuzzy
from .gi_composites import GtkTemplate
@GtkTemplate(ui='/home/wolfv/Programs/uberwriter/uberwriter/plugins/bibtex/bibtex_item.glade')
class BibTexItem(Gtk.Box):
__gtype_name__ = 'BibTexItem'
title_label = GtkTemplate.Child()
author_label = GtkTemplate.Child()
other_label = GtkTemplate.Child()
def __init__(self, data):
super(Gtk.Box, self).__init__()
# This must occur *after* you initialize your base
self.init_template()
self.title_label.set_text(data['title'])
self.author_label.set_text(data.get('author'))
self.other_label.set_text(data.get('year') if data.get('year') else 'N/A')
class BibTex(object):
"""docstring for Handler"""
def open_bibtex(self, event, *args):
self.match()
self.window.show_all()
# self.window.set_transient(True)
# self.window.set_modal(True)
def get_widget_for_box(self, word):
return Gtk.Label(word)
def real_row_activated(self, row, data=None):
print("A row was activated!!")
self.app.TextBuffer.insert_at_cursor('[@' + data + ']')
self.close()
print(data)
def row_activated(self, widget, row, data=None):
# row.activate()
return
def match(self, word=None):
self.rows = []
for i in self.bib_db.entries:
row = Gtk.ListBoxRow()
item = BibTexItem(i)
row.add(item)
row.set_activatable(True)
row.connect('activate', self.real_row_activated, i['ID'])
self.rows.append(row)
self.listview.add(row)
# self.listview.add(Gtk.Label('test'))
# self.listview.bind_model(a, self.get_widget_for_box)
self.listview.show_all()
def __init__(self, app):
self.app = app
self.app.connect('toggle_bibtex', self.open_bibtex)
with open('/home/wolfv/ownCloud/Studium/Semester Project/Report/listb.bib') as f:
self.bib_db = bibtexparser.load(f)
builder = Gtk.Builder()
builder.add_from_file('/home/wolfv/Programs/uberwriter/uberwriter/plugins/bibtex/bibtex.glade')
self.window = builder.get_object('bibtex_window')
self.window.set_transient_for(self.app)
self.window.set_modal(True)
self.listview = builder.get_object('listbox')

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<template class="BibTexItem" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">3</property>
<property name="margin_right">4</property>
<property name="margin_top">3</property>
<property name="margin_bottom">3</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="title_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">label</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="author_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">False</property>
<property name="label" translatable="yes">label</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="other_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</template>
</interface>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<template class="BibTexItem" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="title_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="author_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="other_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</template>
</interface>

View File

@ -0,0 +1,91 @@
"""
BibTeX <http://en.wikipedia.org/wiki/BibTeX> is a bibliographic data file format.
The :mod:`bibtexparser` module provides parsing and writing of BibTeX files functionality. The API is similar to the
:mod:`json` module. The parsed data is returned as a simple :class:`BibDatabase` object with the main attribute being
:attr:`entries` representing bibliographic sources such as books and journal articles.
Parsing is a simple as::
>>>> import bibtexparser
>>>> with open('bibtex.bib') as bibtex_file:
>>>> bibtex_database = bibtexparser.load(bibtex_file)
And writing::
>>>> import bibtexparser
>>>> with open('bibtex.bib', 'w') as bibtex_file:
>>>> bibtexparser.dump(bibtex_database, bibtex_file)
"""
__all__ = [
'loads', 'load', 'dumps', 'dump', 'bibdatabase',
'bparser', 'bwriter', 'latexenc', 'customization',
]
__version__ = '0.6.2'
from . import bibdatabase, bparser, bwriter, latexenc, customization
def loads(bibtex_str, parser=None):
"""
Load :class:`BibDatabase` object from a string
:param bibtex_str: input BibTeX string to be parsed
:type bibtex_str: str or unicode
:param parser: custom parser to use (optional)
:type parser: BibTexParser
:return: bibliographic database object
:rtype: BibDatabase
"""
if parser is None:
parser = bparser.BibTexParser()
return parser.parse(bibtex_str)
def load(bibtex_file, parser=None):
"""
Load :class:`BibDatabase` object from a file
:param bibtex_file: input file to be parsed
:type bibtex_file: file
:param parser: custom parser to use (optional)
:type parser: BibTexParser
:return: bibliographic database object
:rtype: BibDatabase
"""
if parser is None:
parser = bparser.BibTexParser()
return parser.parse_file(bibtex_file)
def dumps(bib_database, writer=None):
"""
Dump :class:`BibDatabase` object to a BibTeX string
:param bib_database: bibliographic database object
:type bib_database: BibDatabase
:param writer: custom writer to use (optional) (not yet implemented)
:type writer: BibTexWriter
:return: BibTeX string
:rtype: unicode
"""
if writer is None:
writer = bwriter.BibTexWriter()
return writer.write(bib_database)
def dump(bib_database, bibtex_file, writer=None):
"""
Save :class:`BibDatabase` object as a BibTeX text file
:param bib_database: bibliographic database object
:type bib_database: BibDatabase
:param bibtex_file: file to write to
:type bibtex_file: file
:param writer: custom writer to use (optional) (not yet implemented)
:type writer: BibTexWriter
"""
if writer is None:
writer = bwriter.BibTexWriter()
bibtex_file.write(writer.write(bib_database))

View File

@ -0,0 +1,57 @@
from collections import OrderedDict
import sys
if sys.version_info.major == 2:
TEXT_TYPE = unicode
else:
TEXT_TYPE = str
class BibDatabase(object):
"""
A bibliographic database object following the data structure of a BibTeX file.
"""
def __init__(self):
#: List of BibTeX entries, for example `@book{...}`, `@article{...}`, etc. Each entry is a simple dict with
#: BibTeX field-value pairs, for example `'author': 'Bird, R.B. and Armstrong, R.C. and Hassager, O.'` Each
#: entry will always have the following dict keys (in addition to other BibTeX fields):
#: - `ID` (BibTeX key)
#: - `ENTRYTYPE` (entry type in lowercase, e.g. `book`, `article` etc.)
self.entries = []
self._entries_dict = {}
#: List of BibTeX comment (`@comment{...}`) blocks.
self.comments = []
#: OrderedDict of BibTeX string definitions (`@string{...}`). In order of definition.
self.strings = OrderedDict() # Not sure if order is import, keep order just in case
#: List of BibTeX preamble (`@preamble{...}`) blocks.
self.preambles = []
def get_entry_list(self):
"""Get a list of bibtex entries.
:returns: BibTeX entries
:rtype: list
.. deprecated:: 0.5.6
Use :attr:`entries` instead.
"""
return self.entries
@staticmethod
def entry_sort_key(entry, fields):
result = []
for field in fields:
result.append(TEXT_TYPE(entry.get(field, '')).lower()) # Sorting always as string
return tuple(result)
def get_entry_dict(self):
"""Return a dictionary of BibTeX entries.
The dict key is the BibTeX entry key
"""
# If the hash has never been made, make it
if not self._entries_dict:
for entry in self.entries:
self._entries_dict[entry['ID']] = entry
return self._entries_dict
entries_dict = property(get_entry_dict)

View File

@ -0,0 +1,422 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Original source: github.com/okfn/bibserver
# Authors:
# markmacgillivray
# Etienne Posthumus (epoz)
# Francois Boulogne <fboulogne at april dot org>
import sys
import logging
import io
import re
from .bibdatabase import BibDatabase
logger = logging.getLogger(__name__)
__all__ = ['BibTexParser']
if sys.version_info >= (3, 0):
from io import StringIO
ustr = str
else:
from StringIO import StringIO
ustr = unicode
class BibTexParser(object):
"""
A parser for reading BibTeX bibliographic data files.
Example::
from bibtexparser.bparser import BibTexParser
bibtex_str = ...
parser = BibTexParser()
parser.ignore_nonstandard_types = False
parser.homogenise_fields = False
bib_database = bibtexparser.loads(bibtex_str, parser)
"""
def __new__(cls, data=None,
customization=None,
ignore_nonstandard_types=True,
homogenise_fields=True):
"""
To catch the old API structure in which creating the parser would immediately parse and return data.
"""
if data is None:
return super(BibTexParser, cls).__new__(cls)
else:
# For backwards compatibility: if data is given, parse and return the `BibDatabase` object instead of the
# parser.
parser = BibTexParser()
parser.customization = customization
parser.ignore_nonstandard_types = ignore_nonstandard_types
parser.homogenise_fields = homogenise_fields
return parser.parse(data)
def __init__(self):
"""
Creates a parser for rading BibTeX files
:return: parser
:rtype: `BibTexParser`
"""
self.bib_database = BibDatabase()
#: Callback function to process BibTeX entries after parsing, for example to create a list from a string with
#: multiple values. By default all BibTeX values are treated as simple strings. Default: `None`.
self.customization = None
#: Ignore non-standard BibTeX types (`book`, `article`, etc). Default: `True`.
self.ignore_nonstandard_types = True
#: Sanitise BibTeX field names, for example change `url` to `link` etc. Field names are always converted to
#: lowercase names. Default: `True`.
self.homogenise_fields = True
# On some sample data files, the character encoding detection simply
# hangs We are going to default to utf8, and mandate it.
self.encoding = 'utf8'
# pre-defined set of key changes
self.alt_dict = {
'keyw': 'keyword',
'keywords': 'keyword',
'authors': 'author',
'editors': 'editor',
'url': 'link',
'urls': 'link',
'links': 'link',
'subjects': 'subject'
}
self.replace_all_re = re.compile(r'((?P<pre>"?)\s*(#|^)\s*(?P<id>[^\d\W]\w*)\s*(#|$)\s*(?P<post>"?))', re.UNICODE)
def _bibtex_file_obj(self, bibtex_str):
# Some files have Byte-order marks inserted at the start
byte = '\xef\xbb\xbf'
if not isinstance(byte, ustr):
byte = ustr('\xef\xbb\xbf', self.encoding, 'ignore')
if bibtex_str[:3] == byte:
bibtex_str = bibtex_str[3:]
return StringIO(bibtex_str)
def parse(self, bibtex_str):
"""Parse a BibTeX string into an object
:param bibtex_str: BibTeX string
:type: str or unicode
:return: bibliographic database
:rtype: BibDatabase
"""
self.bibtex_file_obj = self._bibtex_file_obj(bibtex_str)
self._parse_records(customization=self.customization)
return self.bib_database
def parse_file(self, file):
"""Parse a BibTeX file into an object
:param file: BibTeX file or file-like object
:type: file
:return: bibliographic database
:rtype: BibDatabase
"""
return self.parse(file.read())
def _parse_records(self, customization=None):
"""Parse the bibtex into a list of records.
:param customization: a function
"""
def _add_parsed_record(record, records):
"""
Atomic function to parse a record
and append the result in records
"""
if record != "":
logger.debug('The record is not empty. Let\'s parse it.')
parsed = self._parse_record(record, customization=customization)
if parsed:
logger.debug('Store the result of the parsed record')
records.append(parsed)
else:
logger.debug('Nothing returned from the parsed record!')
else:
logger.debug('The record is empty')
records = []
record = ""
# read each line, bundle them up until they form an object, then send for parsing
for linenumber, line in enumerate(self.bibtex_file_obj):
logger.debug('Inspect line %s', linenumber)
if line.strip().startswith('@'):
# Remove leading whitespaces
line = line.lstrip()
logger.debug('Line starts with @')
# Parse previous record
_add_parsed_record(record, records)
# Start new record
logger.debug('The record is set to empty')
record = ""
# Keep adding lines to the record
record += line
# catch any remaining record and send it for parsing
_add_parsed_record(record, records)
logger.debug('Set the list of entries')
self.bib_database.entries = records
def _parse_record(self, record, customization=None):
"""Parse a record.
* tidy whitespace and other rubbish
* parse out the bibtype and citekey
* find all the key-value pairs it contains
:param record: a record
:param customization: a function
:returns: dict --
"""
d = {}
if not record.startswith('@'):
logger.debug('The record does not start with @. Return empty dict.')
return {}
# if a comment record, add to bib_database.comments
if record.lower().startswith('@comment'):
logger.debug('The record startswith @comment')
logger.debug('Store comment in list of comments')
self.bib_database.comments.append(re.search('\{(.*)\}', record, re.DOTALL).group(1))
logger.debug('Return an empty dict')
return {}
# if a preamble record, add to bib_database.preambles
if record.lower().startswith('@preamble'):
logger.debug('The record startswith @preamble')
logger.debug('Store preamble in list of preambles')
self.bib_database.preambles.append(re.search('\{(.*)\}', record, re.DOTALL).group(1))
logger.debug('Return an empty dict')
return {}
# prepare record
record = '\n'.join([i.strip() for i in record.split('\n')])
if '}\n' in record:
logger.debug('}\\n detected in the record. Clean up.')
record = record.replace('\r\n', '\n').replace('\r', '\n').rstrip('\n')
# treat the case for which the last line of the record
# does not have a coma
if record.endswith('}\n}') or record.endswith('}}'):
logger.debug('Missing coma in the last line of the record. Fix it.')
record = re.sub('}(\n|)}$', '},\n}', record)
# if a string record, put it in the replace_dict
if record.lower().startswith('@string'):
logger.debug('The record startswith @string')
key, val = [i.strip().strip('{').strip('}').replace('\n', ' ') for i in record.split('{', 1)[1].strip('}').strip('\n').strip(',').split('=')]
key = key.lower() # key is case insensitive
val = self._string_subst_partial(val)
if val.startswith('"') or val.lower() not in self.bib_database.strings:
self.bib_database.strings[key] = val.strip('"')
else:
self.bib_database.strings[key] = self.bib_database.strings[val.lower()]
logger.debug('Return a dict')
return d
# for each line in record
logger.debug('Split the record of its lines and treat them')
kvs = [i.strip() for i in re.split(',\s*\n|\n\s*,', record)]
inkey = ""
inval = ""
for kv in kvs:
logger.debug('Inspect: %s', kv)
# TODO: We may check that the keyword belongs to a known type
if kv.startswith('@') and not inkey:
# it is the start of the record - set the bibtype and citekey (id)
logger.debug('Line starts with @ and the key is not stored yet.')
bibtype, id = kv.split('{', 1)
bibtype = self._add_key(bibtype)
id = id.lstrip().strip('}').strip(',')
logger.debug('bibtype = %s', bibtype)
logger.debug('id = %s', id)
if self.ignore_nonstandard_types and bibtype not in ('article',
'book',
'booklet',
'conference',
'inbook',
'incollection',
'inproceedings',
'manual',
'mastersthesis',
'misc',
'phdthesis',
'proceedings',
'techreport',
'unpublished'):
logger.warning('Entry type %s not standard. Not considered.', bibtype)
break
elif '=' in kv and not inkey:
# it is a line with a key value pair on it
logger.debug('Line contains a key-pair value and the key is not stored yet.')
key, val = [i.strip() for i in kv.split('=', 1)]
key = self._add_key(key)
val = self._string_subst_partial(val)
# if it looks like the value spans lines, store details for next loop
if (val.count('{') != val.count('}')) or (val.startswith('"') and not val.replace('}', '').endswith('"')):
logger.debug('The line is not ending the record.')
inkey = key
inval = val
else:
logger.debug('The line is the end of the record.')
d[key] = self._add_val(val)
elif inkey:
logger.debug('Continues the previous line to complete the key pair value...')
# if this line continues the value from a previous line, append
inval += ', ' + kv
# if it looks like this line finishes the value, store it and clear for next loop
if (inval.startswith('{') and inval.endswith('}')) or (inval.startswith('"') and inval.endswith('"')):
logger.debug('This line represents the end of the current key-pair value')
d[inkey] = self._add_val(inval)
inkey = ""
inval = ""
else:
logger.debug('This line does NOT represent the end of the current key-pair value')
logger.debug('All lines have been treated')
if not d:
logger.debug('The dict is empty, return it.')
return d
d['ENTRYTYPE'] = bibtype
d['ID'] = id
if customization is None:
logger.debug('No customization to apply, return dict')
return d
else:
# apply any customizations to the record object then return it
logger.debug('Apply customizations and return dict')
return customization(d)
def _strip_quotes(self, val):
"""Strip double quotes enclosing string
:param val: a value
:type val: string
:returns: string -- value
"""
logger.debug('Strip quotes')
val = val.strip()
if val.startswith('"') and val.endswith('"'):
return val[1:-1]
return val
def _strip_braces(self, val):
"""Strip braces enclosing string
:param val: a value
:type val: string
:returns: string -- value
"""
logger.debug('Strip braces')
val = val.strip()
if val.startswith('{') and val.endswith('}') and self._full_span(val):
return val[1:-1]
return val
def _full_span(self, val):
cnt = 0
for i in range(0, len(val)):
if val[i] == '{':
cnt += 1
elif val[i] == '}':
cnt -= 1
if cnt == 0:
break
if i == len(val) - 1:
return True
else:
return False
def _string_subst(self, val):
""" Substitute string definitions
:param val: a value
:type val: string
:returns: string -- value
"""
logger.debug('Substitute string definitions')
if not val:
return ''
for k in list(self.bib_database.strings.keys()):
if val.lower() == k:
val = self.bib_database.strings[k]
if not isinstance(val, ustr):
val = ustr(val, self.encoding, 'ignore')
return val
def _string_subst_partial(self, val):
""" Substitute string definitions inside larger expressions
:param val: a value
:type val: string
:returns: string -- value
"""
def repl(m):
k = m.group('id')
replacement = self.bib_database.strings[k.lower()] if k.lower() in self.bib_database.strings else k
pre = '"' if m.group('pre') != '"' else ''
post = '"' if m.group('post') != '"' else ''
return pre + replacement + post
logger.debug('Substitute string definitions inside larger expressions')
if '#' not in val:
return val
# TODO?: Does not match two subsequent variables or strings, such as "start" # foo # bar # "end" or "start" # "end".
# TODO: Does not support braces instead of quotes, e.g.: {start} # foo # {bar}
# TODO: Does not support strings like: "te#s#t"
return self.replace_all_re.sub(repl, val)
def _add_val(self, val):
""" Clean instring before adding to dictionary
:param val: a value
:type val: string
:returns: string -- value
"""
if not val or val == "{}":
return ''
val = self._strip_braces(val)
val = self._strip_quotes(val)
val = self._strip_braces(val)
val = self._string_subst(val)
return val
def _add_key(self, key):
""" Add a key and homogeneize alternative forms.
:param key: a key
:type key: string
:returns: string -- value
"""
key = key.strip().strip('@').lower()
if self.homogenise_fields:
if key in list(self.alt_dict.keys()):
key = self.alt_dict[key]
if not isinstance(key, ustr):
return ustr(key, 'utf-8')
else:
return key

View File

@ -0,0 +1,136 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Francois Boulogne
# License:
import logging
from .bibdatabase import BibDatabase
logger = logging.getLogger(__name__)
__all__ = ['BibTexWriter']
def to_bibtex(parsed):
"""
Convenience function for backwards compatibility.
"""
return BibTexWriter().write(parsed)
class BibTexWriter(object):
"""
Writer to convert a :class:`BibDatabase` object to a string or file formatted as a BibTeX file.
Example::
from bibtexparser.bwriter import BibTexWriter
bib_database = ...
writer = BibTexWriter()
writer.contents = ['comments', 'entries']
writer.indent = ' '
writer.order_entries_by = ('ENTRYTYPE', 'author', 'year')
bibtex_str = bibtexparser.dumps(bib_database, writer)
"""
_valid_contents = ['entries', 'comments', 'preambles', 'strings']
def __init__(self):
#: List of BibTeX elements to write, valid values are `entries`, `comments`, `preambles`, `strings`.
self.contents = ['comments', 'preambles', 'strings', 'entries']
#: Character(s) for indenting BibTeX field-value pairs. Default: single space.
self.indent = ' '
#: Align values. Determines the maximal number of characters used in any fieldname and aligns all values
# according to that by filling up with single spaces. Default: False
self.align_values = False
#: Characters(s) for separating BibTeX entries. Default: new line.
self.entry_separator = '\n'
#: Tuple of fields for ordering BibTeX entries. Set to `None` to disable sorting. Default: BibTeX key `('ID', )`.
self.order_entries_by = ('ID', )
#: Tuple of fields for display order in a single BibTeX entry. Fields not listed here will be displayed
#: alphabetically at the end. Set to '[]' for alphabetical order. Default: '[]'
self.display_order = []
#: BibTeX syntax allows comma first syntax
#: (common in functional languages), use this to enable
#: comma first syntax as the bwritter output
self.comma_first = False
#: internal variable used if self.align_values = True
self._max_field_width = 0
def write(self, bib_database):
"""
Converts a bibliographic database to a BibTeX-formatted string.
:param bib_database: bibliographic database to be converted to a BibTeX string
:type bib_database: BibDatabase
:return: BibTeX-formatted string
:rtype: str or unicode
"""
bibtex = ''
for content in self.contents:
try:
# Add each element set (entries, comments)
bibtex += getattr(self, '_' + content + '_to_bibtex')(bib_database)
except AttributeError:
logger.warning("BibTeX item '{}' does not exist and will not be written. Valid items are {}."
.format(content, self._valid_contents))
return bibtex
def _entries_to_bibtex(self, bib_database):
bibtex = ''
if self.order_entries_by:
# TODO: allow sort field does not exist for entry
entries = sorted(bib_database.entries, key=lambda x: BibDatabase.entry_sort_key(x, self.order_entries_by))
else:
entries = bib_database.entries
if self.align_values:
# determine maximum field width to be used
widths = [max(map(len, entry.keys())) for entry in entries]
self._max_field_width = max(widths)
for entry in entries:
bibtex += self._entry_to_bibtex(entry)
return bibtex
def _entry_to_bibtex(self, entry):
bibtex = ''
# Write BibTeX key
bibtex += '@' + entry['ENTRYTYPE'] + '{' + entry['ID']
# create display_order of fields for this entry
# first those keys which are both in self.display_order and in entry.keys
display_order = [i for i in self.display_order if i in entry]
# then all the other fields sorted alphabetically
more_fields = [i for i in sorted(entry) if i not in self.display_order]
display_order += [i for i in sorted(entry) if i not in self.display_order]
# Write field = value lines
for field in [i for i in display_order if i not in ['ENTRYTYPE', 'ID']]:
try:
if self.comma_first:
bibtex += "\n" + self.indent + ", " + "{0:<{1}}".format(field, self._max_field_width) + " = {" + entry[field] + "}"
else:
bibtex += ",\n" + self.indent + "{0:<{1}}".format(field, self._max_field_width) + " = {" + entry[field] + "}"
except TypeError:
raise TypeError(u"The field %s in entry %s must be a string"
% (field, entry['ID']))
bibtex += "\n}\n" + self.entry_separator
return bibtex
def _comments_to_bibtex(self, bib_database):
return ''.join(['@comment{{{0}}}\n{1}'.format(comment, self.entry_separator)
for comment in bib_database.comments])
def _preambles_to_bibtex(self, bib_database):
return ''.join(['@preamble{{{0}}}\n{1}'.format(preamble, self.entry_separator)
for preamble in bib_database.preambles])
def _strings_to_bibtex(self, bib_database):
return ''.join(['@string{{{0} = "{1}"}}\n{2}'.format(name, value, self.entry_separator)
for name, value in bib_database.strings.items()])

View File

@ -0,0 +1,255 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A set of functions useful for customizing bibtex fields.
You can find inspiration from these functions to design yours.
Each of them takes a record and return the modified record.
"""
import itertools
import re
import logging
from .latexenc import unicode_to_latex, unicode_to_crappy_latex1, unicode_to_crappy_latex2, string_to_latex, protect_uppercase
logger = logging.getLogger(__name__)
__all__ = ['getnames', 'author', 'editor', 'journal', 'keyword', 'link',
'page_double_hyphen', 'doi', 'type', 'convert_to_unicode',
'homogeneize_latex_encoding']
def getnames(names):
"""Make people names as surname, firstnames
or surname, initials. Should eventually combine up the two.
:param names: a list of names
:type names: list
:returns: list -- Correctly formated names
"""
tidynames = []
for namestring in names:
namestring = namestring.strip()
if len(namestring) < 1:
continue
if ',' in namestring:
namesplit = namestring.split(',', 1)
last = namesplit[0].strip()
firsts = [i.strip() for i in namesplit[1].split()]
else:
namesplit = namestring.split()
last = namesplit.pop()
firsts = [i.replace('.', '. ').strip() for i in namesplit]
if last in ['jnr', 'jr', 'junior']:
last = firsts.pop()
for item in firsts:
if item in ['ben', 'van', 'der', 'de', 'la', 'le']:
last = firsts.pop() + ' ' + last
tidynames.append(last + ", " + ' '.join(firsts))
return tidynames
def author(record):
"""
Split author field into a list of "Name, Surname".
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
if "author" in record:
if record["author"]:
record["author"] = getnames([i.strip() for i in record["author"].replace('\n', ' ').split(" and ")])
else:
del record["author"]
return record
def editor(record):
"""
Turn the editor field into a dict composed of the original editor name
and a editor id (without coma or blank).
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
if "editor" in record:
if record["editor"]:
record["editor"] = getnames([i.strip() for i in record["editor"].replace('\n', ' ').split(" and ")])
# convert editor to object
record["editor"] = [{"name": i, "ID": i.replace(',', '').replace(' ', '').replace('.', '')} for i in record["editor"]]
else:
del record["editor"]
return record
def page_double_hyphen(record):
"""
Separate pages by a double hyphen (--).
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
if "pages" in record:
# hyphen, non-breaking hyphen, en dash, em dash, hyphen-minus, minus sign
separators = [u'', u'', u'', u'', u'-', u'']
for separator in separators:
if separator in record["pages"]:
p = [i.strip().strip(separator) for i in record["pages"].split(separator)]
record["pages"] = p[0] + '--' + p[-1]
return record
def type(record):
"""
Put the type into lower case.
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
if "type" in record:
record["type"] = record["type"].lower()
return record
def journal(record):
"""
Turn the journal field into a dict composed of the original journal name
and a journal id (without coma or blank).
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
if "journal" in record:
# switch journal to object
if record["journal"]:
record["journal"] = {"name": record["journal"], "ID": record["journal"].replace(',', '').replace(' ', '').replace('.', '')}
return record
def keyword(record, sep=',|;'):
"""
Split keyword field into a list.
:param record: the record.
:type record: dict
:param sep: pattern used for the splitting regexp.
:type record: string, optional
:returns: dict -- the modified record.
"""
if "keyword" in record:
record["keyword"] = [i.strip() for i in re.split(sep, record["keyword"].replace('\n', ''))]
return record
def link(record):
"""
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
if "link" in record:
links = [i.strip().replace(" ", " ") for i in record["link"].split('\n')]
record['link'] = []
for link in links:
parts = link.split(" ")
linkobj = {"url": parts[0]}
if len(parts) > 1:
linkobj["anchor"] = parts[1]
if len(parts) > 2:
linkobj["format"] = parts[2]
if len(linkobj["url"]) > 0:
record["link"].append(linkobj)
return record
def doi(record):
"""
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
if 'doi' in record:
if 'link' not in record:
record['link'] = []
nodoi = True
for item in record['link']:
if 'doi' in item:
nodoi = False
if nodoi:
link = record['doi']
if link.startswith('10'):
link = 'http://dx.doi.org/' + link
record['link'].append({"url": link, "anchor": "doi"})
return record
def convert_to_unicode(record):
"""
Convert accent from latex to unicode style.
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
for val in record:
if '\\' in record[val] or '{' in record[val]:
for k, v in itertools.chain(unicode_to_crappy_latex1, unicode_to_latex):
if v in record[val]:
record[val] = record[val].replace(v, k)
# If there is still very crappy items
if '\\' in record[val]:
for k, v in unicode_to_crappy_latex2:
if v in record[val]:
parts = record[val].split(str(v))
for key, record[val] in enumerate(parts):
if key+1 < len(parts) and len(parts[key+1]) > 0:
# Change order to display accents
parts[key] = parts[key] + parts[key+1][0]
parts[key+1] = parts[key+1][1:]
record[val] = k.join(parts)
return record
def homogeneize_latex_encoding(record):
"""
Homogeneize the latex enconding style for bibtex
This function is experimental.
:param record: the record.
:type record: dict
:returns: dict -- the modified record.
"""
# First, we convert everything to unicode
record = convert_to_unicode(record)
# And then, we fall back
for val in record:
if val not in ('ID',):
logger.debug('Apply string_to_latex to: %s', val)
record[val] = string_to_latex(record[val])
if val == 'title':
logger.debug('Protect uppercase in title')
logger.debug('Before: %s', record[val])
record[val] = protect_uppercase(record[val])
logger.debug('After: %s', record[val])
return record

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,79 @@
#!/usr/bin/env python
# encoding: utf-8
"""
StringMatcher.py
ported from python-Levenshtein
[https://github.com/miohtama/python-Levenshtein]
"""
from Levenshtein import *
from warnings import warn
class StringMatcher:
"""A SequenceMatcher-like class built on the top of Levenshtein"""
def _reset_cache(self):
self._ratio = self._distance = None
self._opcodes = self._editops = self._matching_blocks = None
def __init__(self, isjunk=None, seq1='', seq2=''):
if isjunk:
warn("isjunk not NOT implemented, it will be ignored")
self._str1, self._str2 = seq1, seq2
self._reset_cache()
def set_seqs(self, seq1, seq2):
self._str1, self._str2 = seq1, seq2
self._reset_cache()
def set_seq1(self, seq1):
self._str1 = seq1
self._reset_cache()
def set_seq2(self, seq2):
self._str2 = seq2
self._reset_cache()
def get_opcodes(self):
if not self._opcodes:
if self._editops:
self._opcodes = opcodes(self._editops, self._str1, self._str2)
else:
self._opcodes = opcodes(self._str1, self._str2)
return self._opcodes
def get_editops(self):
if not self._editops:
if self._opcodes:
self._editops = editops(self._opcodes, self._str1, self._str2)
else:
self._editops = editops(self._str1, self._str2)
return self._editops
def get_matching_blocks(self):
if not self._matching_blocks:
self._matching_blocks = matching_blocks(self.get_opcodes(),
self._str1, self._str2)
return self._matching_blocks
def ratio(self):
if not self._ratio:
self._ratio = ratio(self._str1, self._str2)
return self._ratio
def quick_ratio(self):
# This is usually quick enough :o)
if not self._ratio:
self._ratio = ratio(self._str1, self._str2)
return self._ratio
def real_quick_ratio(self):
len1, len2 = len(self._str1), len(self._str2)
return 2.0 * min(len1, len2) / (len1 + len2)
def distance(self):
if not self._distance:
self._distance = distance(self._str1, self._str2)
return self._distance

View File

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '0.8.1'

View File

@ -0,0 +1,263 @@
#!/usr/bin/env python
# encoding: utf-8
"""
fuzz.py
Copyright (c) 2011 Adam Cohen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import unicode_literals
import warnings
try:
from .StringMatcher import StringMatcher as SequenceMatcher
except ImportError:
warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')
from difflib import SequenceMatcher
from . import utils
###########################
# Basic Scoring Functions #
###########################
@utils.check_for_none
@utils.check_empty_string
def ratio(s1, s2):
s1, s2 = utils.make_type_consistent(s1, s2)
m = SequenceMatcher(None, s1, s2)
return utils.intr(100 * m.ratio())
@utils.check_for_none
@utils.check_empty_string
def partial_ratio(s1, s2):
""""Return the ratio of the most similar substring
as a number between 0 and 100."""
s1, s2 = utils.make_type_consistent(s1, s2)
if len(s1) <= len(s2):
shorter = s1
longer = s2
else:
shorter = s2
longer = s1
m = SequenceMatcher(None, shorter, longer)
blocks = m.get_matching_blocks()
# each block represents a sequence of matching characters in a string
# of the form (idx_1, idx_2, len)
# the best partial match will block align with at least one of those blocks
# e.g. shorter = "abcd", longer = XXXbcdeEEE
# block = (1,3,3)
# best score === ratio("abcd", "Xbcd")
scores = []
for block in blocks:
long_start = block[1] - block[0] if (block[1] - block[0]) > 0 else 0
long_end = long_start + len(shorter)
long_substr = longer[long_start:long_end]
m2 = SequenceMatcher(None, shorter, long_substr)
r = m2.ratio()
if r > .995:
return 100
else:
scores.append(r)
return utils.intr(100 * max(scores))
##############################
# Advanced Scoring Functions #
##############################
def _process_and_sort(s, force_ascii):
"""Return a cleaned string with token sorted."""
# pull tokens
tokens = utils.full_process(s, force_ascii=force_ascii).split()
# sort tokens and join
sorted_string = u" ".join(sorted(tokens))
return sorted_string.strip()
# Sorted Token
# find all alphanumeric tokens in the string
# sort those tokens and take ratio of resulting joined strings
# controls for unordered string elements
@utils.check_for_none
def _token_sort(s1, s2, partial=True, force_ascii=True):
sorted1 = _process_and_sort(s1, force_ascii)
sorted2 = _process_and_sort(s2, force_ascii)
if partial:
return partial_ratio(sorted1, sorted2)
else:
return ratio(sorted1, sorted2)
def token_sort_ratio(s1, s2, force_ascii=True):
"""Return a measure of the sequences' similarity between 0 and 100
but sorting the token before comparing.
"""
return _token_sort(s1, s2, partial=False, force_ascii=force_ascii)
def partial_token_sort_ratio(s1, s2, force_ascii=True):
"""Return the ratio of the most similar substring as a number between
0 and 100 but sorting the token before comparing.
"""
return _token_sort(s1, s2, partial=True, force_ascii=force_ascii)
@utils.check_for_none
def _token_set(s1, s2, partial=True, force_ascii=True):
"""Find all alphanumeric tokens in each string...
- treat them as a set
- construct two strings of the form:
<sorted_intersection><sorted_remainder>
- take ratios of those two strings
- controls for unordered partial matches"""
p1 = utils.full_process(s1, force_ascii=force_ascii)
p2 = utils.full_process(s2, force_ascii=force_ascii)
if not utils.validate_string(p1):
return 0
if not utils.validate_string(p2):
return 0
# pull tokens
tokens1 = set(utils.full_process(p1).split())
tokens2 = set(utils.full_process(p2).split())
intersection = tokens1.intersection(tokens2)
diff1to2 = tokens1.difference(tokens2)
diff2to1 = tokens2.difference(tokens1)
sorted_sect = " ".join(sorted(intersection))
sorted_1to2 = " ".join(sorted(diff1to2))
sorted_2to1 = " ".join(sorted(diff2to1))
combined_1to2 = sorted_sect + " " + sorted_1to2
combined_2to1 = sorted_sect + " " + sorted_2to1
# strip
sorted_sect = sorted_sect.strip()
combined_1to2 = combined_1to2.strip()
combined_2to1 = combined_2to1.strip()
if partial:
ratio_func = partial_ratio
else:
ratio_func = ratio
pairwise = [
ratio_func(sorted_sect, combined_1to2),
ratio_func(sorted_sect, combined_2to1),
ratio_func(combined_1to2, combined_2to1)
]
return max(pairwise)
def token_set_ratio(s1, s2, force_ascii=True):
return _token_set(s1, s2, partial=False, force_ascii=force_ascii)
def partial_token_set_ratio(s1, s2, force_ascii=True):
return _token_set(s1, s2, partial=True, force_ascii=force_ascii)
###################
# Combination API #
###################
# q is for quick
def QRatio(s1, s2, force_ascii=True):
p1 = utils.full_process(s1, force_ascii=force_ascii)
p2 = utils.full_process(s2, force_ascii=force_ascii)
if not utils.validate_string(p1):
return 0
if not utils.validate_string(p2):
return 0
return ratio(p1, p2)
def UQRatio(s1, s2):
return QRatio(s1, s2, force_ascii=False)
# w is for weighted
def WRatio(s1, s2, force_ascii=True):
"""Return a measure of the sequences' similarity between 0 and 100,
using different algorithms.
"""
p1 = utils.full_process(s1, force_ascii=force_ascii)
p2 = utils.full_process(s2, force_ascii=force_ascii)
if not utils.validate_string(p1):
return 0
if not utils.validate_string(p2):
return 0
# should we look at partials?
try_partial = True
unbase_scale = .95
partial_scale = .90
base = ratio(p1, p2)
len_ratio = float(max(len(p1), len(p2))) / min(len(p1), len(p2))
# if strings are similar length, don't use partials
if len_ratio < 1.5:
try_partial = False
# if one string is much much shorter than the other
if len_ratio > 8:
partial_scale = .6
if try_partial:
partial = partial_ratio(p1, p2) * partial_scale
ptsor = partial_token_sort_ratio(p1, p2, force_ascii=force_ascii) \
* unbase_scale * partial_scale
ptser = partial_token_set_ratio(p1, p2, force_ascii=force_ascii) \
* unbase_scale * partial_scale
return utils.intr(max(base, partial, ptsor, ptser))
else:
tsor = token_sort_ratio(p1, p2, force_ascii=force_ascii) * unbase_scale
tser = token_set_ratio(p1, p2, force_ascii=force_ascii) * unbase_scale
return utils.intr(max(base, tsor, tser))
def UWRatio(s1, s2):
"""Return a measure of the sequences' similarity between 0 and 100,
using different algorithms. Same as WRatio but preserving unicode.
"""
return WRatio(s1, s2, force_ascii=False)

View File

@ -0,0 +1,227 @@
#!/usr/bin/env python
# encoding: utf-8
"""
process.py
Copyright (c) 2011 Adam Cohen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
import itertools
from . import fuzz
from . import utils
def extract(query, choices, processor=None, scorer=None, limit=5):
"""Select the best match in a list or dictionary of choices.
Find best matches in a list or dictionary of choices, return a
list of tuples containing the match and it's score. If a dictionary
is used, also returns the key for each match.
Arguments:
query: An object representing the thing we want to find.
choices: An iterable or dictionary-like object containing choices
to be matched against the query. Dictionary arguments of
{key: value} pairs will attempt to match the query against
each value.
processor: Optional function of the form f(a) -> b, where a is an
individual choice and b is the choice to be used in matching.
This can be used to match against, say, the first element of
a list:
lambda x: x[0]
Defaults to fuzzywuzzy.utils.full_process().
scorer: Optional function for scoring matches between the query and
an individual processed choice. This should be a function
of the form f(query, choice) -> int.
By default, fuzz.WRatio() is used and expects both query and
choice to be strings.
limit: Optional maximum for the number of elements returned. Defaults
to 5.
Returns:
List of tuples containing the match and its score.
If a list is used for choices, then the result will be 2-tuples.
If a dictionary is used, then the result will be 3-tuples containing
he key for each match.
For example, searching for 'bird' in the dictionary
{'bard': 'train', 'dog': 'man'}
may return
[('train', 22, 'bard'), ('man', 0, 'dog')]
"""
if choices is None:
return []
# Catch generators without lengths
try:
if len(choices) == 0:
return []
except TypeError:
pass
# default, turn whatever the choice is into a workable string
if not processor:
processor = utils.full_process
# default: wratio
if not scorer:
scorer = fuzz.WRatio
sl = []
try:
# See if choices is a dictionary-like object.
for key, choice in choices.items():
processed = processor(choice)
score = scorer(query, processed)
sl.append((choice, score, key))
except AttributeError:
# It's a list; just iterate over it.
for choice in choices:
processed = processor(choice)
score = scorer(query, processed)
sl.append((choice, score))
sl.sort(key=lambda i: i[1], reverse=True)
return sl[:limit]
def extractBests(query, choices, processor=None, scorer=None, score_cutoff=0, limit=5):
"""Get a list of the best matches to a collection of choices.
Convenience function for getting the choices with best scores.
Args:
query: A string to match against
choices: A list or dictionary of choices, suitable for use with
extract().
processor: Optional function for transforming choices before matching.
See extract().
scorer: Scoring function for extract().
score_cutoff: Optional argument for score threshold. No matches with
a score less than this number will be returned. Defaults to 0.
limit: Optional maximum for the number of elements returned. Defaults
to 5.
Returns: A a list of (match, score) tuples.
"""
best_list = extract(query, choices, processor, scorer, limit)
return list(itertools.takewhile(lambda x: x[1] >= score_cutoff, best_list))
def extractOne(query, choices, processor=None, scorer=None, score_cutoff=0):
"""Find the single best match above a score in a list of choices.
This is a convenience method which returns the single best choice.
See extract() for the full arguments list.
Args:
query: A string to match against
choices: A list or dictionary of choices, suitable for use with
extract().
processor: Optional function for transforming choices before matching.
See extract().
scorer: Scoring function for extract().
score_cutoff: Optional argument for score threshold. If the best
match is found, but it is not greater than this number, then
return None anyway ("not a good enough match"). Defaults to 0.
Returns:
A tuple containing a single match and its score, if a match
was found that was above score_cutoff. Otherwise, returns None.
"""
best_list = extract(query, choices, processor, scorer, limit=1)
if len(best_list) > 0 and best_list[0][1] >= score_cutoff:
return best_list[0]
return None
def dedupe(contains_dupes, threshold=70, scorer=fuzz.token_set_ratio):
"""This convenience function takes a list of strings containing duplicates and uses fuzzy matching to identify
and remove duplicates. Specifically, it uses the process.extract to identify duplicates that
score greater than a user defined threshold. Then, it looks for the longest item in the duplicate list
since we assume this item contains the most entity information and returns that. It breaks string
length ties on an alphabetical sort.
Note: as the threshold DECREASES the number of duplicates that are found INCREASES. This means that the
returned deduplicated list will likely be shorter. Raise the threshold for fuzzy_dedupe to be less
sensitive.
Args:
contains_dupes: A list of strings that we would like to dedupe.
threshold: the numerical value (0,100) point at which we expect to find duplicates.
Defaults to 70 out of 100
scorer: Optional function for scoring matches between the query and
an individual processed choice. This should be a function
of the form f(query, choice) -> int.
By default, fuzz.token_set_ratio() is used and expects both query and
choice to be strings.
Returns:
A deduplicated list. For example:
In: contains_dupes = ['Frodo Baggin', 'Frodo Baggins', 'F. Baggins', 'Samwise G.', 'Gandalf', 'Bilbo Baggins']
In: fuzzy_dedupe(contains_dupes)
Out: ['Frodo Baggins', 'Samwise G.', 'Bilbo Baggins', 'Gandalf']
"""
extractor = []
# iterate over items in *contains_dupes*
for item in contains_dupes:
# return all duplicate matches found
matches = extract(item, contains_dupes, limit=None, scorer=scorer)
# filter matches based on the threshold
filtered = [x for x in matches if x[1] > threshold]
# if there is only 1 item in *filtered*, no duplicates were found so append to *extracted*
if len(filtered) == 1:
extractor.append(filtered[0][0])
else:
# alpha sort
filtered = sorted(filtered, key=lambda x: x[0])
# length sort
filter_sort = sorted(filtered, key=lambda x: len(x[0]), reverse=True)
# take first item as our 'canonical example'
extractor.append(filter_sort[0][0])
# uniquify *extractor* list
keys = {}
for e in extractor:
keys[e] = 1
extractor = keys.keys()
# check that extractor differs from contain_dupes (e.g. duplicates were found)
# if not, then return the original list
if len(extractor) == len(contains_dupes):
return contains_dupes
else:
return extractor

View File

@ -0,0 +1,34 @@
from __future__ import unicode_literals
import re
import string
import sys
PY3 = sys.version_info[0] == 3
class StringProcessor(object):
"""
This class defines method to process strings in the most
efficient way. Ideally all the methods below use unicode strings
for both input and output.
"""
regex = re.compile(r"(?ui)\W")
@classmethod
def replace_non_letters_non_numbers_with_whitespace(cls, a_string):
"""
This function replaces any sequence of non letters and non
numbers with a single white space.
"""
return cls.regex.sub(u" ", a_string)
if PY3:
strip = staticmethod(str.strip)
to_lower_case = staticmethod(str.lower)
to_upper_case = staticmethod(str.upper)
else:
strip = staticmethod(string.strip)
to_lower_case = staticmethod(string.lower)
to_upper_case = staticmethod(string.upper)

View File

@ -0,0 +1,94 @@
from __future__ import unicode_literals
import sys
import functools
from fuzzywuzzy.string_processing import StringProcessor
PY3 = sys.version_info[0] == 3
def validate_string(s):
try:
return len(s) > 0
except TypeError:
return False
def check_for_none(func):
@functools.wraps(func)
def decorator(*args, **kwargs):
if args[0] is None:
raise TypeError("s1 is None")
if args[1] is None:
raise TypeError("s2 is None")
return func(*args, **kwargs)
return decorator
def check_empty_string(func):
@functools.wraps(func)
def decorator(*args, **kwargs):
if len(args[0]) == 0 or len(args[1]) == 0:
return 0
return func(*args, **kwargs)
return decorator
bad_chars = str("").join([chr(i) for i in range(128, 256)]) # ascii dammit!
if PY3:
translation_table = dict((ord(c), None) for c in bad_chars)
unicode = str
def asciionly(s):
if PY3:
return s.translate(translation_table)
else:
return s.translate(None, bad_chars)
def asciidammit(s):
if type(s) is str:
return asciionly(s)
elif type(s) is unicode:
return asciionly(s.encode('ascii', 'ignore'))
else:
return asciidammit(unicode(s))
def make_type_consistent(s1, s2):
"""If both objects aren't either both string or unicode instances force them to unicode"""
if isinstance(s1, str) and isinstance(s2, str):
return s1, s2
elif isinstance(s1, unicode) and isinstance(s2, unicode):
return s1, s2
else:
return unicode(s1), unicode(s2)
def full_process(s, force_ascii=False):
"""Process string by
-- removing all but letters and numbers
-- trim whitespace
-- force to lower case
if force_ascii == True, force convert to ascii"""
if s is None:
return ""
if force_ascii:
s = asciidammit(s)
# Keep only Letters and Numbers (see Unicode docs).
string_out = StringProcessor.replace_non_letters_non_numbers_with_whitespace(s)
# Force into lowercase.
string_out = StringProcessor.to_lower_case(string_out)
# Remove leading and trailing whitespaces.
string_out = StringProcessor.strip(string_out)
return string_out
def intr(n):
'''Returns a correctly rounded integer'''
return int(round(n))

View File

@ -0,0 +1,276 @@
#
# Copyright (C) 2015 Dustin Spicuzza <dustin@virtualroadside.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA
from os.path import abspath, join
import inspect
import warnings
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gtk
__all__ = ['GtkTemplate']
class GtkTemplateWarning(UserWarning):
pass
def _connect_func(builder, obj, signal_name, handler_name,
connect_object, flags, cls):
'''Handles GtkBuilder signal connect events'''
if connect_object is None:
extra = ()
else:
extra = (connect_object,)
# The handler name refers to an attribute on the template instance,
# so ask GtkBuilder for the template instance
template_inst = builder.get_object(cls.__gtype_name__)
if template_inst is None: # This should never happen
errmsg = "Internal error: cannot find template instance! obj: %s; " \
"signal: %s; handler: %s; connect_obj: %s; class: %s" % \
(obj, signal_name, handler_name, connect_object, cls)
warnings.warn(errmsg, GtkTemplateWarning)
return
handler = getattr(template_inst, handler_name)
if flags == GObject.ConnectFlags.AFTER:
obj.connect_after(signal_name, handler, *extra)
else:
obj.connect(signal_name, handler, *extra)
template_inst.__connected_template_signals__.add(handler_name)
def _register_template(cls, template_bytes):
'''Registers the template for the widget and hooks init_template'''
# This implementation won't work if there are nested templates, but
# we can't do that anyways due to PyGObject limitations so it's ok
if not hasattr(cls, 'set_template'):
raise TypeError("Requires PyGObject 3.13.2 or greater")
cls.set_template(template_bytes)
bound_methods = set()
bound_widgets = set()
# Walk the class, find marked callbacks and child attributes
for name in dir(cls):
o = getattr(cls, name, None)
if inspect.ismethod(o):
if hasattr(o, '_gtk_callback'):
bound_methods.add(name)
# Don't need to call this, as connect_func always gets called
#cls.bind_template_callback_full(name, o)
elif isinstance(o, _Child):
cls.bind_template_child_full(name, True, 0)
bound_widgets.add(name)
# Have to setup a special connect function to connect at template init
# because the methods are not bound yet
cls.set_connect_func(_connect_func, cls)
cls.__gtemplate_methods__ = bound_methods
cls.__gtemplate_widgets__ = bound_widgets
base_init_template = cls.init_template
cls.init_template = lambda s: _init_template(s, cls, base_init_template)
def _init_template(self, cls, base_init_template):
'''This would be better as an override for Gtk.Widget'''
# TODO: could disallow using a metaclass.. but this is good enough
# .. if you disagree, feel free to fix it and issue a PR :)
if self.__class__ is not cls:
raise TypeError("Inheritance from classes with @GtkTemplate decorators "
"is not allowed at this time")
connected_signals = set()
self.__connected_template_signals__ = connected_signals
base_init_template(self)
print('initing template')
print(self.__gtemplate_widgets__)
for name in self.__gtemplate_widgets__:
widget = self.get_template_child(cls, name)
self.__dict__[name] = widget
print(name)
if widget is None:
# Bug: if you bind a template child, and one of them was
# not present, then the whole template is broken (and
# it's not currently possible for us to know which
# one is broken either -- but the stderr should show
# something useful with a Gtk-CRITICAL message)
raise AttributeError("A missing child widget was set using "
"GtkTemplate.Child and the entire "
"template is now broken (widgets: %s)" %
', '.join(self.__gtemplate_widgets__))
for name in self.__gtemplate_methods__.difference(connected_signals):
errmsg = ("Signal '%s' was declared with @GtkTemplate.Callback " +
"but was not present in template") % name
warnings.warn(errmsg, GtkTemplateWarning)
# TODO: Make it easier for IDE to introspect this
class _Child(object):
'''
Assign this to an attribute in your class definition and it will
be replaced with a widget defined in the UI file when init_template
is called
'''
__slots__ = []
@staticmethod
def widgets(count):
'''
Allows declaring multiple widgets with less typing::
button \
label1 \
label2 = GtkTemplate.Child.widgets(3)
'''
return [_Child() for _ in range(count)]
class _GtkTemplate(object):
'''
Use this class decorator to signify that a class is a composite
widget which will receive widgets and connect to signals as
defined in a UI template. You must call init_template to
cause the widgets/signals to be initialized from the template::
@GtkTemplate(ui='foo.ui')
class Foo(Gtk.Box):
def __init__(self):
super(Foo, self).__init__()
self.init_template()
The 'ui' parameter can either be a file path or a GResource resource
path::
@GtkTemplate(ui='/org/example/foo.ui')
class Foo(Gtk.Box):
pass
To connect a signal to a method on your instance, do::
@GtkTemplate.Callback
def on_thing_happened(self, widget):
pass
To create a child attribute that is retrieved from your template,
add this to your class definition::
@GtkTemplate(ui='foo.ui')
class Foo(Gtk.Box):
widget = GtkTemplate.Child()
Note: This is implemented as a class decorator, but if it were
included with PyGI I suspect it might be better to do this
in the GObject metaclass (or similar) so that init_template
can be called automatically instead of forcing the user to do it.
.. note:: Due to limitations in PyGObject, you may not inherit from
python objects that use the GtkTemplate decorator.
'''
__ui_path__ = None
@staticmethod
def Callback(f):
'''
Decorator that designates a method to be attached to a signal from
the template
'''
f._gtk_callback = True
return f
Child = _Child
@staticmethod
def set_ui_path(*path):
'''
If using file paths instead of resources, call this *before*
loading anything that uses GtkTemplate, or it will fail to load
your template file
:param path: one or more path elements, will be joined together
to create the final path
TODO: Alternatively, could wait until first class instantiation
before registering templates? Would need a metaclass...
'''
_GtkTemplate.__ui_path__ = abspath(join(*path))
def __init__(self, ui):
self.ui = ui
def __call__(self, cls):
if not issubclass(cls, Gtk.Widget):
raise TypeError("Can only use @GtkTemplate on Widgets")
# Nested templates don't work
if hasattr(cls, '__gtemplate_methods__'):
raise TypeError("Cannot nest template classes")
# Load the template either from a resource path or a file
# - Prefer the resource path first
try:
template_bytes = Gio.resources_lookup_data(self.ui, Gio.ResourceLookupFlags.NONE)
except GLib.GError:
ui = self.ui
if isinstance(ui, (list, tuple)):
ui = join(ui)
if _GtkTemplate.__ui_path__ is not None:
ui = join(_GtkTemplate.__ui_path__, ui)
with open(ui, 'rb') as fp:
template_bytes = GLib.Bytes.new(fp.read())
_register_template(cls, template_bytes)
return cls
# Future shim support if this makes it into PyGI?
#if hasattr(Gtk, 'GtkTemplate'):
# GtkTemplate = lambda c: c
#else:
GtkTemplate = _GtkTemplate

@ -0,0 +1 @@
Subproject commit 264ee48c1fe05ef2198697e88f34bae581654caa

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<object class="GtkTextBuffer" id="textbuffer1">
<signal name="changed" handler="recompile_image" swapped="no"/>
</object>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<signal name="delete-event" handler="onDeleteWindow" swapped="no"/>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="stock">gtk-justify-center</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="textview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="buffer">textbuffer1</property>
<signal name="key-press-event" handler="textview_after_key_pressed" after="yes" swapped="no"/>
<signal name="key-press-event" handler="textview_key_pressed" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="searchentry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_bottom">5</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<signal name="search-changed" handler="searchentry_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="listbox">
<property name="name">listbox</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="activate_on_single_click">False</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">3</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,10 @@
<?xml version='1.0'?>
<!-- This file was generated by dvisvgm 1.6 -->
<svg height='4.64012pt' version='1.1' viewBox='-144 -143.973 19.8509 4.64012' width='19.8509pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<path d='M7.23288 -3.25778C7.65131 -2.89913 8.1594 -2.6401 8.48817 -2.49066C8.12951 -2.33126 7.64134 -2.07223 7.23288 -1.72354H0.9066C0.737235 -1.72354 0.547945 -1.72354 0.547945 -1.52428S0.727273 -1.32503 0.896638 -1.32503H6.78456C6.30635 -0.86675 5.78829 0.00996264 5.78829 0.139477C5.78829 0.249066 5.91781 0.249066 5.97758 0.249066C6.05729 0.249066 6.12702 0.249066 6.16687 0.169365C6.37609 -0.209215 6.65504 -0.737235 7.30262 -1.31507C7.99004 -1.92279 8.65753 -2.19178 9.17559 -2.34122C9.34496 -2.401 9.35492 -2.41096 9.37484 -2.43088C9.39477 -2.44085 9.39477 -2.47073 9.39477 -2.49066S9.39477 -2.53051 9.38481 -2.55044L9.35492 -2.57036C9.33499 -2.58032 9.32503 -2.59029 9.13574 -2.65006C7.79078 -3.04857 6.79452 -3.95517 6.23661 -5.02117C6.12702 -5.22042 6.11706 -5.23039 5.97758 -5.23039C5.91781 -5.23039 5.78829 -5.23039 5.78829 -5.1208C5.78829 -4.99128 6.29639 -4.12453 6.78456 -3.65629H0.896638C0.727273 -3.65629 0.547945 -3.65629 0.547945 -3.45704S0.737235 -3.25778 0.9066 -3.25778H7.23288Z' id='g0-41'/>
</defs>
<g id='page1' transform='matrix(2 0 0 2 0 0)'>
<use x='-72' xlink:href='#g0-41' y='-68.345'/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,12 @@
<?xml version='1.0'?>
<!-- This file was generated by dvisvgm 1.6 -->
<svg height='13.2135pt' version='1.1' viewBox='-144 -143.978 19.9559 13.2135' width='19.9559pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<path d='M3.32752 -3.00872C3.3873 -3.26775 3.61644 -4.18431 4.31382 -4.18431C4.36364 -4.18431 4.60274 -4.18431 4.81196 -4.05479C4.533 -4.00498 4.33375 -3.75592 4.33375 -3.51681C4.33375 -3.35741 4.44334 -3.16812 4.71233 -3.16812C4.93151 -3.16812 5.25031 -3.34745 5.25031 -3.74595C5.25031 -4.26401 4.66252 -4.40349 4.32379 -4.40349C3.74595 -4.40349 3.39726 -3.87547 3.27771 -3.64633C3.02864 -4.30386 2.49066 -4.40349 2.20174 -4.40349C1.16563 -4.40349 0.597758 -3.11831 0.597758 -2.86924C0.597758 -2.76961 0.697385 -2.76961 0.71731 -2.76961C0.797011 -2.76961 0.826899 -2.78954 0.846824 -2.8792C1.18555 -3.93524 1.84309 -4.18431 2.18182 -4.18431C2.37111 -4.18431 2.7198 -4.09465 2.7198 -3.51681C2.7198 -3.20797 2.55044 -2.54047 2.18182 -1.1457C2.02242 -0.52802 1.67372 -0.109589 1.23537 -0.109589C1.17559 -0.109589 0.946451 -0.109589 0.737235 -0.239103C0.986301 -0.288917 1.20548 -0.498132 1.20548 -0.777086C1.20548 -1.04608 0.986301 -1.12578 0.836862 -1.12578C0.537983 -1.12578 0.288917 -0.86675 0.288917 -0.547945C0.288917 -0.0896638 0.787049 0.109589 1.2254 0.109589C1.88294 0.109589 2.24159 -0.587796 2.27148 -0.647572C2.39103 -0.278954 2.74969 0.109589 3.34745 0.109589C4.3736 0.109589 4.94147 -1.17559 4.94147 -1.42466C4.94147 -1.52428 4.85181 -1.52428 4.82192 -1.52428C4.73225 -1.52428 4.71233 -1.48443 4.6924 -1.41469C4.36364 -0.348692 3.68618 -0.109589 3.36737 -0.109589C2.97883 -0.109589 2.81943 -0.428394 2.81943 -0.767123C2.81943 -0.986301 2.8792 -1.20548 2.98879 -1.64384L3.32752 -3.00872Z' id='g0-120'/>
<path d='M2.94296 -2.66401C2.79651 -2.89415 2.5594 -3.07547 2.22466 -3.07547C1.332 -3.07547 0.425405 -2.09215 0.425405 -1.08792C0.425405 -0.411457 0.878705 0.0697385 1.47846 0.0697385C1.85504 0.0697385 2.18979 -0.146451 2.46874 -0.418431C2.60125 0 3.00573 0.0697385 3.18705 0.0697385C3.43811 0.0697385 3.61245 -0.0836862 3.73798 -0.299875C3.89141 -0.571856 3.98207 -0.969365 3.98207 -0.99726C3.98207 -1.08792 3.89141 -1.08792 3.87049 -1.08792C3.77285 -1.08792 3.76588 -1.06002 3.71706 -0.871731C3.63337 -0.536986 3.50087 -0.125529 3.20797 -0.125529C3.02665 -0.125529 2.97783 -0.278954 2.97783 -0.467248C2.97783 -0.585803 3.03362 -0.836862 3.08244 -1.01818C3.13126 -1.20648 3.201 -1.4924 3.23587 -1.64583L3.37534 -2.17584C3.41719 -2.35716 3.50087 -2.68493 3.50087 -2.7198C3.50087 -2.87323 3.37534 -2.94296 3.26376 -2.94296C3.14521 -2.94296 2.98481 -2.85928 2.94296 -2.66401ZM2.49664 -0.871731C2.44782 -0.676463 2.2944 -0.536986 2.14097 -0.404483C2.07821 -0.348692 1.79925 -0.125529 1.49938 -0.125529C1.24134 -0.125529 0.990286 -0.306849 0.990286 -0.801993C0.990286 -1.17161 1.19253 -1.93873 1.35293 -2.21768C1.67372 -2.77559 2.02939 -2.8802 2.22466 -2.8802C2.71283 -2.8802 2.84533 -2.35019 2.84533 -2.27347C2.84533 -2.24558 2.83138 -2.19676 2.82441 -2.17584L2.49664 -0.871731Z' id='g1-97'/>
</defs>
<g id='page1' transform='matrix(2 0 0 2 0 0)'>
<use x='-72' xlink:href='#g0-120' y='-65.382'/>
<use x='-66.3273' xlink:href='#g1-97' y='-68.9974'/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,12 @@
<?xml version='1.0'?>
<!-- This file was generated by dvisvgm 1.6 -->
<svg height='11.5356pt' version='1.1' viewBox='-144 -143.968 19.9559 11.5356' width='19.9559pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<path d='M3.32752 -3.00872C3.3873 -3.26775 3.61644 -4.18431 4.31382 -4.18431C4.36364 -4.18431 4.60274 -4.18431 4.81196 -4.05479C4.533 -4.00498 4.33375 -3.75592 4.33375 -3.51681C4.33375 -3.35741 4.44334 -3.16812 4.71233 -3.16812C4.93151 -3.16812 5.25031 -3.34745 5.25031 -3.74595C5.25031 -4.26401 4.66252 -4.40349 4.32379 -4.40349C3.74595 -4.40349 3.39726 -3.87547 3.27771 -3.64633C3.02864 -4.30386 2.49066 -4.40349 2.20174 -4.40349C1.16563 -4.40349 0.597758 -3.11831 0.597758 -2.86924C0.597758 -2.76961 0.697385 -2.76961 0.71731 -2.76961C0.797011 -2.76961 0.826899 -2.78954 0.846824 -2.8792C1.18555 -3.93524 1.84309 -4.18431 2.18182 -4.18431C2.37111 -4.18431 2.7198 -4.09465 2.7198 -3.51681C2.7198 -3.20797 2.55044 -2.54047 2.18182 -1.1457C2.02242 -0.52802 1.67372 -0.109589 1.23537 -0.109589C1.17559 -0.109589 0.946451 -0.109589 0.737235 -0.239103C0.986301 -0.288917 1.20548 -0.498132 1.20548 -0.777086C1.20548 -1.04608 0.986301 -1.12578 0.836862 -1.12578C0.537983 -1.12578 0.288917 -0.86675 0.288917 -0.547945C0.288917 -0.0896638 0.787049 0.109589 1.2254 0.109589C1.88294 0.109589 2.24159 -0.587796 2.27148 -0.647572C2.39103 -0.278954 2.74969 0.109589 3.34745 0.109589C4.3736 0.109589 4.94147 -1.17559 4.94147 -1.42466C4.94147 -1.52428 4.85181 -1.52428 4.82192 -1.52428C4.73225 -1.52428 4.71233 -1.48443 4.6924 -1.41469C4.36364 -0.348692 3.68618 -0.109589 3.36737 -0.109589C2.97883 -0.109589 2.81943 -0.428394 2.81943 -0.767123C2.81943 -0.986301 2.8792 -1.20548 2.98879 -1.64384L3.32752 -3.00872Z' id='g0-120'/>
<path d='M2.94296 -2.66401C2.79651 -2.89415 2.5594 -3.07547 2.22466 -3.07547C1.332 -3.07547 0.425405 -2.09215 0.425405 -1.08792C0.425405 -0.411457 0.878705 0.0697385 1.47846 0.0697385C1.85504 0.0697385 2.18979 -0.146451 2.46874 -0.418431C2.60125 0 3.00573 0.0697385 3.18705 0.0697385C3.43811 0.0697385 3.61245 -0.0836862 3.73798 -0.299875C3.89141 -0.571856 3.98207 -0.969365 3.98207 -0.99726C3.98207 -1.08792 3.89141 -1.08792 3.87049 -1.08792C3.77285 -1.08792 3.76588 -1.06002 3.71706 -0.871731C3.63337 -0.536986 3.50087 -0.125529 3.20797 -0.125529C3.02665 -0.125529 2.97783 -0.278954 2.97783 -0.467248C2.97783 -0.585803 3.03362 -0.836862 3.08244 -1.01818C3.13126 -1.20648 3.201 -1.4924 3.23587 -1.64583L3.37534 -2.17584C3.41719 -2.35716 3.50087 -2.68493 3.50087 -2.7198C3.50087 -2.87323 3.37534 -2.94296 3.26376 -2.94296C3.14521 -2.94296 2.98481 -2.85928 2.94296 -2.66401ZM2.49664 -0.871731C2.44782 -0.676463 2.2944 -0.536986 2.14097 -0.404483C2.07821 -0.348692 1.79925 -0.125529 1.49938 -0.125529C1.24134 -0.125529 0.990286 -0.306849 0.990286 -0.801993C0.990286 -1.17161 1.19253 -1.93873 1.35293 -2.21768C1.67372 -2.77559 2.02939 -2.8802 2.22466 -2.8802C2.71283 -2.8802 2.84533 -2.35019 2.84533 -2.27347C2.84533 -2.24558 2.83138 -2.19676 2.82441 -2.17584L2.49664 -0.871731Z' id='g1-97'/>
</defs>
<g id='page1' transform='matrix(2 0 0 2 0 0)'>
<use x='-72' xlink:href='#g0-120' y='-67.7105'/>
<use x='-66.3273' xlink:href='#g1-97' y='-66.2162'/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,10 @@
<?xml version='1.0'?>
<!-- This file was generated by dvisvgm 1.6 -->
<svg height='8.54689pt' version='1.1' viewBox='-144 -143.968 12.7721 8.54689' width='12.7721pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<path d='M4.75218 -2.35118C4.75218 -3.91532 3.82565 -4.40349 3.08842 -4.40349C1.72354 -4.40349 0.408468 -2.97883 0.408468 -1.5741C0.408468 -0.647572 1.00623 0.109589 2.02242 0.109589C2.65006 0.109589 3.36737 -0.119552 4.12453 -0.727273C4.25405 -0.199253 4.58281 0.109589 5.03113 0.109589C5.55915 0.109589 5.868 -0.438356 5.868 -0.597758C5.868 -0.667497 5.80822 -0.697385 5.74844 -0.697385C5.6787 -0.697385 5.64882 -0.667497 5.61893 -0.597758C5.4396 -0.109589 5.08095 -0.109589 5.06102 -0.109589C4.75218 -0.109589 4.75218 -0.886675 4.75218 -1.12578C4.75218 -1.33499 4.75218 -1.35492 4.85181 -1.47447C5.78829 -2.65006 5.99751 -3.80573 5.99751 -3.81569C5.99751 -3.83562 5.98755 -3.91532 5.87796 -3.91532C5.77833 -3.91532 5.77833 -3.88543 5.72852 -3.7061C5.54919 -3.07846 5.22042 -2.3213 4.75218 -1.7335V-2.35118ZM4.08468 -0.986301C3.20797 -0.219178 2.44085 -0.109589 2.04234 -0.109589C1.44458 -0.109589 1.1457 -0.557908 1.1457 -1.19552C1.1457 -1.68369 1.40473 -2.75965 1.72354 -3.26775C2.19178 -3.99502 2.72976 -4.18431 3.07846 -4.18431C4.06476 -4.18431 4.06476 -2.8792 4.06476 -2.10212C4.06476 -1.7335 4.06476 -1.15567 4.08468 -0.986301Z' id='g0-11'/>
</defs>
<g id='page1' transform='matrix(2 0 0 2 0 0)'>
<use x='-72' xlink:href='#g0-11' y='-67.7105'/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,10 @@
<?xml version='1.0'?>
<!-- This file was generated by dvisvgm 1.6 -->
<svg height='17.6452pt' version='1.1' viewBox='-144 -143.948 12.2758 17.6452' width='12.2758pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<path d='M5.72852 -5.66874C5.72852 -6.41594 5.18057 -7.03362 4.3736 -7.03362C3.79577 -7.03362 3.51681 -6.87422 3.16812 -6.61519C2.62017 -6.21669 2.07223 -5.25031 1.88294 -4.49315L0.298879 1.83313C0.288917 1.87298 0.33873 1.93275 0.418431 1.93275S0.52802 1.91283 0.537983 1.88294L1.23537 -0.86675C1.42466 -0.268991 1.86301 0.0996264 2.59029 0.0996264S4.06476 -0.249066 4.51308 -0.687422C4.99128 -1.1457 5.31009 -1.78331 5.31009 -2.52055C5.31009 -3.23786 4.94147 -3.75592 4.58281 -4.00498C5.16065 -4.33375 5.72852 -4.95143 5.72852 -5.66874ZM3.93524 -4.01494C3.80573 -3.96513 3.69614 -3.94521 3.45704 -3.94521C3.31756 -3.94521 3.11831 -3.93524 3.01868 -3.98506C3.03861 -4.08468 3.39726 -4.06476 3.50685 -4.06476C3.71606 -4.06476 3.80573 -4.06476 3.93524 -4.01494ZM5.17061 -5.89788C5.17061 -5.2005 4.79203 -4.48319 4.27397 -4.17435C4.00498 -4.27397 3.80573 -4.2939 3.50685 -4.2939C3.29763 -4.2939 2.73973 -4.30386 2.73973 -3.97509C2.72976 -3.69614 3.24782 -3.72603 3.42715 -3.72603C3.79577 -3.72603 3.94521 -3.73599 4.24408 -3.85554C4.62267 -3.49689 4.67248 -3.18804 4.68244 -2.72976C4.70237 -2.15193 4.46326 -1.40473 4.18431 -1.01619C3.79577 -0.478207 3.12827 -0.119552 2.5604 -0.119552C1.80324 -0.119552 1.42466 -0.697385 1.42466 -1.40473C1.42466 -1.50436 1.42466 -1.6538 1.47447 -1.84309L2.11208 -4.36364C2.33126 -5.22042 3.04857 -6.80448 4.24408 -6.80448C4.82192 -6.80448 5.17061 -6.49564 5.17061 -5.89788Z' id='g0-12'/>
</defs>
<g id='page1' transform='matrix(2 0 0 2 0 0)'>
<use x='-72' xlink:href='#g0-12' y='-65.0815'/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,16 @@
<?xml version='1.0'?>
<!-- This file was generated by dvisvgm 1.6 -->
<svg height='27.8594pt' version='1.1' viewBox='-144 -143.964 33.1982 27.8594' width='33.1982pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<path d='M3.94521 -3.7858C3.7858 -3.7858 3.64633 -3.7858 3.50685 -3.64633C3.34745 -3.49689 3.32752 -3.32752 3.32752 -3.25778C3.32752 -3.01868 3.50685 -2.90909 3.69614 -2.90909C3.98506 -2.90909 4.25405 -3.14819 4.25405 -3.5467C4.25405 -4.03487 3.7858 -4.40349 3.07846 -4.40349C1.7335 -4.40349 0.408468 -2.97883 0.408468 -1.5741C0.408468 -0.67746 0.986301 0.109589 2.02242 0.109589C3.44707 0.109589 4.28394 -0.946451 4.28394 -1.066C4.28394 -1.12578 4.22416 -1.19552 4.16438 -1.19552C4.11457 -1.19552 4.09465 -1.17559 4.03487 -1.09589C3.24782 -0.109589 2.16189 -0.109589 2.04234 -0.109589C1.41469 -0.109589 1.1457 -0.597758 1.1457 -1.19552C1.1457 -1.60399 1.34496 -2.57036 1.68369 -3.18804C1.99253 -3.75592 2.54047 -4.18431 3.08842 -4.18431C3.42715 -4.18431 3.80573 -4.05479 3.94521 -3.7858Z' id='g0-99'/>
<path d='M2.94296 -2.66401C2.79651 -2.89415 2.5594 -3.07547 2.22466 -3.07547C1.332 -3.07547 0.425405 -2.09215 0.425405 -1.08792C0.425405 -0.411457 0.878705 0.0697385 1.47846 0.0697385C1.85504 0.0697385 2.18979 -0.146451 2.46874 -0.418431C2.60125 0 3.00573 0.0697385 3.18705 0.0697385C3.43811 0.0697385 3.61245 -0.0836862 3.73798 -0.299875C3.89141 -0.571856 3.98207 -0.969365 3.98207 -0.99726C3.98207 -1.08792 3.89141 -1.08792 3.87049 -1.08792C3.77285 -1.08792 3.76588 -1.06002 3.71706 -0.871731C3.63337 -0.536986 3.50087 -0.125529 3.20797 -0.125529C3.02665 -0.125529 2.97783 -0.278954 2.97783 -0.467248C2.97783 -0.585803 3.03362 -0.836862 3.08244 -1.01818C3.13126 -1.20648 3.201 -1.4924 3.23587 -1.64583L3.37534 -2.17584C3.41719 -2.35716 3.50087 -2.68493 3.50087 -2.7198C3.50087 -2.87323 3.37534 -2.94296 3.26376 -2.94296C3.14521 -2.94296 2.98481 -2.85928 2.94296 -2.66401ZM2.49664 -0.871731C2.44782 -0.676463 2.2944 -0.536986 2.14097 -0.404483C2.07821 -0.348692 1.79925 -0.125529 1.49938 -0.125529C1.24134 -0.125529 0.990286 -0.306849 0.990286 -0.801993C0.990286 -1.17161 1.19253 -1.93873 1.35293 -2.21768C1.67372 -2.77559 2.02939 -2.8802 2.22466 -2.8802C2.71283 -2.8802 2.84533 -2.35019 2.84533 -2.27347C2.84533 -2.24558 2.83138 -2.19676 2.82441 -2.17584L2.49664 -0.871731Z' id='g1-97'/>
<path d='M1.8411 -4.63064C1.84807 -4.64458 1.86899 -4.73524 1.86899 -4.74222C1.86899 -4.77709 1.8411 -4.83985 1.75741 -4.83985C1.61793 -4.83985 1.0391 -4.78406 0.864757 -4.77011C0.808966 -4.76314 0.711333 -4.75616 0.711333 -4.60971C0.711333 -4.51208 0.808966 -4.51208 0.892653 -4.51208C1.2274 -4.51208 1.2274 -4.46326 1.2274 -4.40747C1.2274 -4.35866 1.15766 -4.0797 1.11582 -3.9193L0.955417 -3.27771C0.892653 -3.0406 0.509091 -1.51333 0.495143 -1.42267C0.460274 -1.25529 0.460274 -1.16463 0.460274 -1.08095C0.460274 -0.376588 0.9066 0.0697385 1.48543 0.0697385C2.35716 0.0697385 3.28468 -0.878705 3.28468 -1.91083C3.28468 -2.72677 2.7198 -3.07547 2.23861 -3.07547C1.87597 -3.07547 1.56912 -2.87323 1.3599 -2.69191L1.8411 -4.63064ZM1.4924 -0.125529C1.15068 -0.125529 0.955417 -0.425405 0.955417 -0.836862C0.955417 -1.09489 1.01818 -1.332 1.21345 -2.12005C1.25529 -2.25255 1.25529 -2.2665 1.3878 -2.41993C1.6528 -2.72677 1.96663 -2.8802 2.21768 -2.8802C2.48966 -2.8802 2.72677 -2.67796 2.72677 -2.20374C2.72677 -1.91781 2.57335 -1.20648 2.36413 -0.801993C2.19676 -0.460274 1.84807 -0.125529 1.4924 -0.125529Z' id='g1-98'/>
<path d='M2.70984 8.76712C2.58032 10.401 2.22167 10.8493 1.6538 10.8493C1.52428 10.8493 1.2254 10.8194 1.01619 10.6401C1.30511 10.6002 1.38481 10.3711 1.38481 10.2316C1.38481 9.94271 1.16563 9.8132 0.976339 9.8132C0.777086 9.8132 0.557908 9.94271 0.557908 10.2416C0.557908 10.7198 1.05604 11.0685 1.6538 11.0685C2.60025 11.0685 3.07846 10.2017 3.29763 9.30511C3.42715 8.78705 3.7858 5.88792 3.8655 4.78207L4.05479 2.30137C4.19427 0.468244 4.533 0.219178 4.98132 0.219178C5.08095 0.219178 5.38979 0.239103 5.60897 0.428394C5.32005 0.468244 5.24035 0.697385 5.24035 0.836862C5.24035 1.12578 5.45953 1.25529 5.64882 1.25529C5.84807 1.25529 6.06725 1.12578 6.06725 0.826899C6.06725 0.348692 5.56912 0 4.97136 0C4.02491 0 3.63636 0.966376 3.467 1.72354C3.34745 2.27148 2.98879 5.08095 2.89913 6.28643L2.70984 8.76712Z' id='g2-82'/>
</defs>
<g id='page1' transform='matrix(2 0 0 2 0 0)'>
<use x='-72' xlink:href='#g2-82' y='-69.62'/>
<use x='-65.3582' xlink:href='#g1-98' y='-67.1571'/>
<use x='-67.2954' xlink:href='#g1-97' y='-58.0522'/>
<use x='-59.6962' xlink:href='#g0-99' y='-61.5945'/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -0,0 +1,5 @@
<?xml version='1.0'?>
<!-- This file was generated by dvisvgm 1.6 -->
<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<g id='page1' transform='matrix(2 0 0 2 0 0)'/>
</svg>

After

Width:  |  Height:  |  Size: 223 B