Skip to content

Instantly share code, notes, and snippets.

View kergoth's full-sized avatar

Christopher Larson kergoth

  • Siemens Digital Industries Software
  • X @kergoth
View GitHub Profile
@kergoth
kergoth / oe_uri.py
Created September 10, 2010 03:49
Experimentations with a Url class
import re
from uri import parse_url, Url
class MalformedUrl(Exception):
pass
def new_decodeurl(url):
uri = parse_url(url)
return uri.scheme, uri.hostname or '', uri.path, uri.username or '', uri.password or '', uri.params
@kergoth
kergoth / README.rst
Created November 26, 2010 21:03
Prototype bitbake recipe parser using the python 'lepl' module

Prototype bitbake recipe parser using the python 'lepl' module

TODO

  • Handle line continuations with \
  • Handle \n, \r, etc within values without breaking line continuations
  • Handle python functions defined with 'def'. Note: might want to use the line-aware parsing for this.
  • Experiment with using lepl's lexer via its Token objects.
@kergoth
kergoth / compile.py
Last active November 28, 2019 21:48
Testing python function compilation from strings with line number adjustment
#!/usr/bin/env python
"""Utility functions for compiling python functions from strings, and
for dealing with exceptions from them"""
import ast
import inspect
import sys
import traceback
from collections import namedtuple
try:
@kergoth
kergoth / data.py
Created December 17, 2010 18:40
OE bitbake metadata wrapper class
import bb.data_smart
import oe.types
class Data(bb.data_smart.DataSmart):
def __init__(self, parent):
if parent:
super(Data, self).__init__(seen=parent._seen_overrides.copy(),
special=parent._special_values.copy())
self.dict["_data"] = parent.dict
else:
@kergoth
kergoth / namedtuple_with_abc.py
Created January 7, 2011 15:19
namedtuple with default value for fields
#!/usr/bin/env python
# Copyright (c) 2011 Jan Kaliszewski (zuo). Available under the MIT License.
"""
namedtuple_with_abc.py:
* named tuple mix-in + ABC (abstract base class) recipe,
* works under Python 2.6, 2.7 as well as 3.x.
Import this module to patch collections.namedtuple() factory function
-- enriching it with the 'abc' attribute (an abstract base class + mix-in
@kergoth
kergoth / sync.py
Created January 17, 2011 15:32 — forked from kennethreitz/sync.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Kenneth Reitz's GitHub Syncer
This script uses the GitHub API to get a list of all forked, mirrored, public, and
private repos in your GitHub account. If the repo already exists locally, it will
update it via git-pull. Otherwise, it will properly clone the repo.
It will organize your repos into the following directory structure:
@kergoth
kergoth / colorlog.py
Last active April 7, 2021 13:45
Colorizing log handler
# Courtesy http://plumberjack.blogspot.com/2010/12/colorizing-logging-output-in-terminals.html
# Tweaked to use colorama for the coloring
import colorama
import logging
import re
import sys
def remove_ansi(s):
@kergoth
kergoth / runqueue-pool.py
Created February 16, 2011 02:56
Prototype / Experimentations with an alternative runqueue task executor
import multiprocessing
import os
import sys
import bb.data, bb.cache
from queue import Empty
class Task(object):
def __init__(self, taskid, name, fn, taskhash, appends):
self.hash = taskhash
@kergoth
kergoth / assume.bbclass
Created March 14, 2011 18:36
Automatic ASSUME_PROVIDED based upon what's available in the build machine (not for the faint of heart, you've been warned)
def auto_assume_provided():
import kergoth.assume as assume
import kergoth.assumptions
return ' '.join(assume.test_assumptions())
ASSUME_PROVIDED += "${@auto_assume_provided()}"
@kergoth
kergoth / git-cached-clone
Created March 21, 2011 19:11
Clone a url, caching it, so all clones of a given url share the same core set of git objects
#!/bin/sh
#
# git-cached-clone
#
# Clone a url to a destination, as git clone does, but cache as well, such
# that all clones of a given url share the same core git objects, which saves
# disk space and reduces the load on the git server. This is transparent to
# the user of the cloned repository, as it still points at upstream, and
# future updates from that clone will use the original URL, not the cache.
#