

import glob
import os

# List of commands the paasta client can execute
CMDS = None


def paasta_commands():
    """
    Read the files names in the cmds directory to determine the various commands
    the paasta client is able to execute
    :return: a list of string such as ['list','check'] that correspond to a
    file in cmds
    """
    global CMDS

    if CMDS is None:

        CMDS = []

        path = "%s/cmds/*.py" % os.path.abspath('.')

        for file_name in glob.glob(path):
            start = file_name.rfind('/') + 1
            end = file_name.rfind('.')
            CMDS.append(file_name[start:end])

        # Remove __init__.py
        CMDS.sort()
        CMDS.pop(0)

    return CMDS



import glob
import os


def paasta_commands():
    """
    Read the files names in the cmds directory to determine the various commands
    the paasta client is able to execute
    :return: a list of string such as ['list','check'] that correspond to a
    file in cmds
    """
    path = '%s/cmds/*.py' % os.path.abspath('.')
    for file_name in glob.glob(path):
        basename = os.path.basename(file_name)
        root, _ = os.path.splitext(basename)
        if root == '__init__':
            continue
        yield root
Clean up directory parsing code
Clean up directory parsing code

  
  
  import glob
  import os
- 
- # List of commands the paasta client can execute
- CMDS = None
  
  
  def paasta_commands():
      """
      Read the files names in the cmds directory to determine the various commands
      the paasta client is able to execute
      :return: a list of string such as ['list','check'] that correspond to a
      file in cmds
      """
-     global CMDS
- 
-     if CMDS is None:
- 
-         CMDS = []
- 
-         path = "%s/cmds/*.py" % os.path.abspath('.')
+     path = '%s/cmds/*.py' % os.path.abspath('.')
- 
-         for file_name in glob.glob(path):
+     for file_name in glob.glob(path):
+         basename = os.path.basename(file_name)
+         root, _ = os.path.splitext(basename)
+         if root == '__init__':
+             continue
+         yield root
-             start = file_name.rfind('/') + 1
-             end = file_name.rfind('.')
-             CMDS.append(file_name[start:end])
- 
-         # Remove __init__.py
-         CMDS.sort()
-         CMDS.pop(0)
- 
-     return CMDS
- 
Clean up directory parsing code
## Code Before:


import glob
import os

# List of commands the paasta client can execute
CMDS = None


def paasta_commands():
    """
    Read the files names in the cmds directory to determine the various commands
    the paasta client is able to execute
    :return: a list of string such as ['list','check'] that correspond to a
    file in cmds
    """
    global CMDS

    if CMDS is None:

        CMDS = []

        path = "%s/cmds/*.py" % os.path.abspath('.')

        for file_name in glob.glob(path):
            start = file_name.rfind('/') + 1
            end = file_name.rfind('.')
            CMDS.append(file_name[start:end])

        # Remove __init__.py
        CMDS.sort()
        CMDS.pop(0)

    return CMDS

## Instruction:
Clean up directory parsing code
## Code After:


import glob
import os


def paasta_commands():
    """
    Read the files names in the cmds directory to determine the various commands
    the paasta client is able to execute
    :return: a list of string such as ['list','check'] that correspond to a
    file in cmds
    """
    path = '%s/cmds/*.py' % os.path.abspath('.')
    for file_name in glob.glob(path):
        basename = os.path.basename(file_name)
        root, _ = os.path.splitext(basename)
        if root == '__init__':
            continue
        yield root