Skip to content

Instantly share code, notes, and snippets.

@hubertgrzeskowiak
Last active December 24, 2019 04:35
Show Gist options
  • Save hubertgrzeskowiak/8802720 to your computer and use it in GitHub Desktop.
Save hubertgrzeskowiak/8802720 to your computer and use it in GitHub Desktop.
This small script converts a .classpath file as Eclipse IDE creates it into a colon-separated CLASSPATH line which you can use as command line parameter to Java or as environment variable.
#!/bin/env python
"""
This small script converts a .classpath file as Eclipse IDE creates it into a colon-separated
CLASSPATH line which you can use as command line parameter to Java or as environment variable.
"""
import sys
from bs4 import BeautifulSoup as bs
if len(sys.argv) != 2:
print "Please provide path to .classpath as parameter"
sys.exit(1)
cpfile = open(sys.argv[1]).read()
soup = bs(cpfile)
entries = []
for entry in soup.find_all("classpathentry"):
entries.append(entry.attrs["path"])
if "output" in entry.attrs:
entries.append(entry.attrs["output"])
print ":".join(entries)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment