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 / lupa_bb_test.py
Created April 11, 2011 21:06
Playing with lupa for lua embedded in python
import sys
sys.path[0:0] = ["./lib"]
import bb.data
import lupa
lua = lupa.LuaRuntime()
env = lua.eval("setmetatable({}, {__index = _G})")
setfenv = lua.globals().setfenv
def eval_lua(luastr, d):
@kergoth
kergoth / README.rst
Created May 10, 2011 00:38
Experiments with splitting the lexer out of the parser for BitBake's file format

TODO

  • Verify that IndentTokenizer works with a non-LINE-based tokenizer specification, rather than the default
  • Resurrect the 'NEWLINE' token, as we need it to be as picky about the file format as the current parser is
  • Implement a parser which leverages this to properly change the lexer states for both ordinary functions and "def" syntax functions. Determine if this should be custom or PLY or codetalker or what, by first determining whether these libraries would support a lexer like ours
  • Do performance testing comparing the new parser against the old, and against the pyparsing implementation
@kergoth
kergoth / fsm.py
Created May 25, 2011 16:08
One of the simpler state machine implementations I've run across
# Copyright Mike Sweeney, placed under the MIT license
# See http://code.activestate.com/recipes/577701-a-flexible-state-machine-class/ for reference
class StateMachine:
def __init__(self, transitions, initial=None):
if isinstance(transitions, basestring):
components = [term.split(':') for term in transitions.split()]
self.sm = dict([tuple(a.split(',')), tuple(b.split(','))]
for a, b in components)
#!/usr/bin/env lua5.0
-- A Factory generates an object that is able to construct other objects,
-- via the :new() method. Note that it does NOT do anything with metatables.
-- That is up to the appropriate init() function.
-- As a simple example, a Class is essentially an object factory, with fancy
-- initialization for its subclasses for inheritence.
--
-- local Class = Factory(Object, Object)
-- Class.class = Class
# Pre-fetching sources into DL_DIR
d = oe.data.DataStore(d)
for uri in (oe.fetcher(uri, d.DL_DIR) for uri in d.SRC_URI):
try:
uri.cache()
except oe.FetchError as exc:
bb.fatal(str(exc))
# Downloading sources into WORKDIR
d = oe.data.DataStore(d)
INCOMPATIBLE_LICENSE ?= ""
LICENSE_PRIORITY = "\
MIT \
LGPL-2.0 LGPL-2.1 \
GPL-2.0 GPL-2.0 \
* \
LGPL-3.0 GPL-3.0 \
Proprietary CLOSED \
${INCOMPATIBLE_LICENSE} \
"
@kergoth
kergoth / pstats-browser.py
Created February 19, 2012 01:32
The interactive part of pstats.py from the python source, modified slightly to allow multiple profile data files as arguments
#!/usr/bin/env python
# The interactive part of pstats.py from the python source, modified slightly to allow
# multiple profile data files as arguments. It initializes the stats object with the
# first argument, then adds the data from the others to that object.
import sys
from pstats import Stats
import cmd
try:

This is just some experimentation with bitbake-like things from scratch in go

To test:

export GOPATH=$HOME/code/go # or similar, if not set already
go get github.com/skelterjohn/go-gb/gb
export PATH=$GOPATH/bin:$PATH
gb
./test/test
@kergoth
kergoth / bitbake-json.patch
Created May 25, 2012 14:25
Playing around with json in bitbake
diff --git i/lib/bb/parse/ast.py w/lib/bb/parse/ast.py
index eae840f..2fa5664 100644
--- i/lib/bb/parse/ast.py
+++ w/lib/bb/parse/ast.py
@@ -102,13 +102,23 @@ class DataNode(AstNode):
bb.data.update_data(e)
val = e.expand(groupd["value"], key + "[:=]")
elif "append" in groupd and groupd["append"] != None:
- val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"])
+ val = self.getFunc(key, data) or ""
@kergoth
kergoth / clean-sstate
Created July 13, 2012 14:53
Clean out shared state archives not used in the past week (requires mount with atime)
#!/bin/sh
time=+6 # older than 7 days ago
cache_paths () {
locate -ebr '^cached-binaries\|sstate-cache$'
echo /cache/sstate
}
readlinks () {