def development_eggs(): """Return list of development egg directories from unstable.cfg. Zest assumption: we've placed them in src/* """ unstable_lines = open('unstable.cfg').read().split('\n') part = buildoututils.extract_parts(unstable_lines, partname=PARTNAME) if not part: logger.error("No [%s] part, unstable.cfg isn't up-to-date.", PARTNAME) return (start, end, specs, url_section) = buildoututils.extract_option( unstable_lines, 'urls', startline=part['start'], endline=part['end']) development_eggs = [] for spec in specs: url, name = spec.split() development_eggs.append('src/%s' % name) return development_eggs
def remove_old_part(): """If PARTNAME already exists, remove it""" stable_lines = open('stable.cfg').read().split('\n') old_part = buildoututils.extract_parts(stable_lines, partname=PARTNAME) if old_part: del stable_lines[old_part['start']:old_part['end']] contents = '\n'.join(stable_lines) open('stable.cfg', 'w').write(contents) logger.debug("New stable.cfg written: old part removed.")
def url_list(): """Return version lines""" stable_lines = open('stable.cfg').read().split('\n') part = buildoututils.extract_parts(stable_lines, partname=PARTNAME) if not part: return [] (start, end, specs, url_section) = buildoututils.extract_option( stable_lines, 'urls', startline=part['start'], endline=part['end']) # http://somethinglong/tags/xyz something interesting = [spec.split('tags/')[1] for spec in specs] logger.debug("Version lines: %s", interesting) return interesting
def develop_to_infrae(): """Move development eggs from 'develop=' to infrae.subversion""" unstable_lines = open('unstable.cfg').read().splitlines() buildout_part = buildoututils.extract_parts(unstable_lines, partname='buildout') if not buildout_part: logger.debug("No [buildout] part, so I'm not looking for dev eggs") return (start, end, directories, development_section) = buildoututils.extract_option( unstable_lines, 'develop', startline=buildout_part['start'], endline=buildout_part['end']) if not directories: logger.debug("No develop section in [buildout].") return # Remove develop contents new = ['develop =', ''] unstable_lines[start:end] = new contents = '\n'.join(unstable_lines) # Add newline at end of file: contents += '\n' open('unstable.cfg', 'w').write(contents) # Write new part checkouts = [] start_dir = os.path.abspath('.') for directory in directories: logger.debug("Determining svn url for %s...", directory) os.chdir(directory) url = utils.svn_info() checkouts.append(url) os.chdir(start_dir) stabilize.add_new_part(checkouts, filename='unstable.cfg') logger.info("Moved development eggs to infrae.subversion.") logger.info("Make sure part %s is actually called.", stabilize.PARTNAME) logger.info("Make sure ${%s:eggs} is actually included.", stabilize.PARTNAME) logger.info("Delete src/ dir from svn and add it to svn:ignore.")
def add_new_part(tags, filename='stable.cfg'): """Add PARTNAME part""" new = ['[%s]' % PARTNAME] new.append('recipe = infrae.subversion >= 1.4') checkouts = [] for tag, name in tags: checkouts.append('%s %s' % (tag, name)) lines = buildoututils.format_option('urls', checkouts) new += lines new.append('as_eggs = true') new.append('location = src') new.append('') new.append('') lines = open(filename).read().splitlines() first = buildoututils.extract_parts(lines)[0] insertion_point = first['end'] lines[insertion_point:insertion_point] = new contents = '\n'.join(lines) # Add newline at end of file: contents += '\n' open(filename, 'w').write(contents) logger.debug("New %s written. Added %s", filename, new)