text
stringlengths
0
828
referent = obj()
if referent is None:
return ""weakref (dead referent)""
else:
return ""weakref to id 0x{:x}"".format(id(referent))
elif isinstance(obj, types.FrameType):
filename = obj.f_code.co_filename
if len(filename) > FRAME_FILENAME_LIMIT:
filename = ""..."" + filename[-(FRAME_FILENAME_LIMIT-3):]
return ""frame\\n{}:{}"".format(
filename,
obj.f_lineno,
)
else:
return ""object\\n{}.{}"".format(
type(obj).__module__,
type(obj).__name__,
)"
858,"def disttar(target, source, env):
""""""tar archive builder""""""
import tarfile
env_dict = env.Dictionary()
if env_dict.get(""DISTTAR_FORMAT"") in [""gz"", ""bz2""]:
tar_format = env_dict[""DISTTAR_FORMAT""]
else:
tar_format = """"
# split the target directory, filename, and stuffix
base_name = str(target[0]).split('.tar')[0]
(target_dir, dir_name) = os.path.split(base_name)
# create the target directory if it does not exist
if target_dir and not os.path.exists(target_dir):
os.makedirs(target_dir)
# open our tar file for writing
print >> sys.stderr, 'DistTar: Writing %s' % str(target[0])
print >> sys.stderr, ' with contents: %s' % [str(s) for s in source]
tar = tarfile.open(str(target[0]), ""w:%s"" % tar_format)
# write sources to our tar file
for item in source:
item = str(item)
sys.stderr.write(""."")
#print ""Adding to TAR file: %s/%s"" % (dir_name,item)
tar.add(item,'%s/%s' % (dir_name,item))
# all done
sys.stderr.write(""\n"") #print ""Closing TAR file""
tar.close()"
859,"def disttar_suffix(env, sources):
""""""tar archive suffix generator""""""
env_dict = env.Dictionary()
if env_dict.has_key(""DISTTAR_FORMAT"") and env_dict[""DISTTAR_FORMAT""] in [""gz"", ""bz2""]:
return "".tar."" + env_dict[""DISTTAR_FORMAT""]
else:
return "".tar"""
860,"def generate(env):
""""""
Add builders and construction variables for the DistTar builder.
""""""
disttar_action=SCons.Action.Action(disttar, disttar_string)
env['BUILDERS']['DistTar'] = Builder(
action=disttar_action
, emitter=disttar_emitter
, suffix = disttar_suffix
, target_factory = env.fs.Entry
)
env.AppendUnique(
DISTTAR_FORMAT = 'gz'
)"
861,"def ensure_table(self, cls):
""""""Ensure table's existence - as per the gludb spec.""""""
id_len = len(uuid())
index_names = cls.index_names() or []
cols = [
'id char(%d) primary key' % (id_len,),
'value jsonb'
] + [
name + ' text' for name in index_names
]
table_name = cls.get_table_name()
with self._conn() as conn:
with conn.cursor() as cur:
cur.execute('create table if not exists %s (%s);' % (
table_name,
','.join(cols)
))
for name in index_names:
cur.execute('create index if not exists %s on %s(%s);' % (
table_name + '_' + name + '_idx',
table_name,