Exemple #1
0
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")
Exemple #2
0
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")
Exemple #3
0
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")