예제 #1
0
파일: gen.py 프로젝트: jelec/codeSynergy
def codeProject(args,flag,data):
  PARAM_KEY = 1
  PARAM_PATH = 2
  PARAM_FORMATTER = 3
  ARGUMENTS = len(args)-1

  # JSON mapping files and storage of this
  if( keyExists("projects",args[1])):
    if( "stdout" in args[2]):
      project = json.loads(load("projects/"+args[PARAM_KEY])); # Uses key value storage
      directory = args[PARAM_PATH] + "/" + args[PARAM_KEY]
      
      mkdir(directory)
      for x in project.keys(): # Reflect that with here
        _file = json.loads(load("files/"+x));
        out = '';
        for y in _file:
          block = str(load("blocks/"+ y))
          if(ARGUMENTS == PARAM_FORMATTER): # Alter all the blocks in said fashion
            block = format.block(block, args[PARAM_FORMATTER])     
          out += block
        # Output the file with the correct file name
        save(directory + "/" + project[x],out)

  else:
    error("Error: Project does not exist")
예제 #2
0
파일: gen.py 프로젝트: jelec/codeSynergy
def codeFile(args,flag,data): 
  PARAM_KEY = 1;
  PARAM_FILE = 2; # Output file location
  PARAM_FORMATTER = 3
  ARGUMENTS = len(args)-1
  # Ability to add a block of code through copy and paste and have it formatted correctly!
  if( keyExists("files",args[PARAM_KEY])):
    _file = json.loads(load("files/"+args[PARAM_KEY]));
    out = ''

    # loadJSON 
    for x in _file:
      block = str(load("blocks/"+ x))
      if(ARGUMENTS == PARAM_FORMATTER): # Alter all the blocks in said fashion
        block = format.block(block, args[PARAM_FORMATTER])     
      out += block
      out += "\n" # Adds some spacing between blocks

    # No file specified
    if(len(args) < 3 ): 
      log(out)
    else:
      log("Saving to file "+ args[PARAM_FILE] )
      save(args[PARAM_FILE],out)
  else:
    error("Error: File does not exist")
예제 #3
0
def main():
  tests = 0
  testspassed = 0
  print "-------- Welcome to the format test ----------"
  print "----------------------------------------------"
  test("world world world",format.block("hello world hello", "hello:world"),tests, testspassed)
  print "Test Result " + str(testspassed) + "/" + str(tests) + " have passed."
예제 #4
0
파일: gen.py 프로젝트: jelec/codeSynergy
def createFile(_file, formating, formatFlag):
  out = "" # Output string
  for x in _file:
      block = str(load("blocks/"+ x))
      if(formatFlag): # Alter all the blocks in said fashion
        block = format.block(block, formating)     
      out += block
      out += "\n" # Adds some spacing between blocks

  return out
예제 #5
0
파일: gen.py 프로젝트: jelec/codeSynergy
def codeBlock(args,flag,data):
  PARAM_KEY = 1
  PARAM_FORMATTER = 2
  PARAM_FILE = 3
  PARAM_LINE = 4
  ARGUMENTS = len(args)-1

  # Ability to add a block of code through copy and paste and have it formatted correctly!
  if( keyExists("blocks",args[PARAM_KEY])):
    block = load("blocks/"+args[PARAM_KEY])
    # Format these blocks
    if(ARGUMENTS == PARAM_FORMATTER): # Format blocks
      block = format.block(block, args[PARAM_FORMATTER])
    if(ARGUMENTS <= PARAM_FORMATTER): # No file specified
      log(block)
    else:
      if(ARGUMENTS == PARAM_FILE): 
        log("Saving to file "+ args[PARAM_FILE] )
        save(args[PARAM_FILE],block)
      elif(ARGUMENTS >= PARAM_LINE): # Argument for line 
        save(args[PARAM_FILE],block,args[PARAM_LINE])
  else:
    error("Error: Block does not exist")