This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#from lxml import etree | |
from flask import Flask, request, Response, render_template, abort | |
from oaipmh import server, metadata | |
from oai_auth import auth_info, ip_check_init, ip_to_inst, set_auth, get_ip | |
import logging | |
import re | |
import ss_server | |
def getServer(): |
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
@restrict(internal_access=True) | |
def index(request): | |
params = request.params | |
account = request.account | |
project, asset_group = _find_project_and_asset_group(request.db, | |
request.matchdict) | |
res = Asset.search_by_project(account, project, asset_group, params) | |
if params.get("with_meta", False) == "true": | |
return extjs.configure_asset_panel(account, project, res) | |
else: |
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
# Wanted to test the penalty for using imports inside functions. | |
import timeit | |
def t1(): | |
return 2 * 2 | |
timeit.timeit("t1()", setup="from __main__ import t1") | |
#> 0.14718103408813477 |
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
var ExcelSuccessDialog = Ext.extend(Ext.Window, { | |
constructor: function(config) { | |
this.importsuccessForm = new Ext.FormPanel({ | |
frame: true, | |
bodyStyle: 'padding: 10px 10px 0 10px;', | |
labelWidth: 50, | |
defaults: { anchor: '95%', allowBlank: false, msgTarget: 'side'}, | |
items: [{ | |
xtype: 'displayfield', | |
itemID: 'numnew', |
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.publishRecordAction = new Ext.Action({ | |
text: 'Publish', | |
disabled: true, | |
handler: function() { | |
if(this.getSelectedRecords().length > 0) { | |
var params = new Object(); | |
params.asset_ids = this.getSelectedRecords().map(function(r) { return r.id; }); | |
Ext.Ajax.request({ | |
url: Imata.config.asset_publish_url(1, "publish"), | |
method: 'POST', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sharedshelf.tests import * | |
from sharedshelf.lib import imatacache | |
class TestImataCache(TestCase): | |
def test_adding_value_to_cache(self): | |
cache = imatacache.ImataCache() | |
myvalue = 'bar' | |
key = cache.add(myvalue) | |
self.assertEqual(myvalue, cache.get(key)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_init_file = "/".join(__file__.split('/')[:-3])+"/test.ini" | |
if not os.path.isfile(test_init_file): | |
print "Expected "+test_init_file+" to be present." | |
exit(-1) | |
SetupCommand('setup-app').run([test_init_file]) |
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
@classmethod | |
def create_from_dict(cls, project, profile_id, data_dict, asset_group=None): | |
"""Takes a dict with field_definition ids mapped to values and returns a new asset""" | |
asset = Asset(profile_id) | |
asset.update_from_dict(data_dict) | |
asset.project = project | |
# for fd in project.field_definitions: | |
# if fd.id in data_dict.keys(): | |
# asset.set_field_value(fd, data_dict[fd.id]) | |
return asset |
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
# Lisp like toy in Python | |
# (c) William Groppe, 2010 | |
import re | |
import collections | |
SHOW_REDUCTIONS = False | |
OP_BEGIN = "(" | |
OP_END = ")" |
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
def tuplify(ws): | |
out = dict() | |
for r in range(0, ws.get_highest_row()): | |
for c in range(0, ws.get_highest_column()): | |
# openpyxl uses 1,1 as origin we expect 0,0 | |
out[(r,c)] = ws.cell(row=r+1, column=c+1).value | |
return out | |
def check_if_xlxs(filename): | |
from openpyxl.reader.excel import load_workbook |
NewerOlder