-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from 9seconds/v0.2
0.2
- Loading branch information
Showing
16 changed files
with
328 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
import collections | ||
import os.path | ||
import warnings | ||
|
||
|
||
Templater = collections.namedtuple("Templater", ["name", "render"]) | ||
|
||
EXTRAS = {"templater": Templater(None, lambda content: content)} | ||
HOME_DIR = os.path.expanduser("~") | ||
DEFAULT_RC = os.path.join(HOME_DIR, ".conciergerc") | ||
DEFAULT_SSHCONFIG = os.path.join(HOME_DIR, ".ssh", "config") | ||
|
||
|
||
try: | ||
import mako.template | ||
except ImportError: | ||
pass | ||
else: | ||
EXTRAS["templater"] = Templater( | ||
"Mako", | ||
lambda content: mako.template.Template(content).render_unicode()) | ||
|
||
|
||
if EXTRAS["templater"].name is None: | ||
try: | ||
import jinja2 | ||
except ImportError: | ||
pass | ||
else: | ||
EXTRAS["templater"] = Templater( | ||
"Jinja2", | ||
lambda content: jinja2.Environment().from_string(content).render()) | ||
warnings.simplefilter('always', DeprecationWarning) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
import atexit | ||
|
||
|
||
try: | ||
import pgi | ||
except ImportError: | ||
pgi = None | ||
else: | ||
pgi.install_as_gi() | ||
|
||
import gi | ||
|
||
gi.require_version("Notify", "0.7") | ||
|
||
from gi.repository import Notify | ||
|
||
Notify.init("concierge") | ||
atexit.register(Notify.uninit) | ||
|
||
|
||
def dummy_notifier(_): | ||
pass | ||
|
||
|
||
notifier = dummy_notifier | ||
|
||
if pgi: | ||
def libnotify_notifier(problem): | ||
Notify.Notification.new("concierge", problem, None).show() | ||
|
||
notifier = libnotify_notifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
import pkg_resources | ||
|
||
|
||
TEMPLATER_NAMESPACE = "concierge.templater" | ||
DEFAULT_RESOLVE_SEQ = "mako", "jinja2" | ||
|
||
|
||
def all_templaters(): | ||
templaters = {"dummy": Templater} | ||
|
||
for plugin in pkg_resources.iter_entry_points(group=TEMPLATER_NAMESPACE): | ||
templaters[plugin.name] = plugin.load() | ||
|
||
return templaters | ||
|
||
|
||
def resolve_templater(choose=None): | ||
templaters = all_templaters() | ||
found = None | ||
|
||
if choose: | ||
found = templaters[choose] | ||
else: | ||
for code in DEFAULT_RESOLVE_SEQ: | ||
if code in templaters: | ||
found = templaters[code] | ||
break | ||
else: | ||
found = Templater | ||
|
||
return found() | ||
|
||
|
||
class Templater(object): | ||
|
||
name = "dummy" | ||
"""The name of the templater to show.""" | ||
|
||
def render(self, content): | ||
return content |
Oops, something went wrong.