
from glob import iglob

import luigi

from tasks.config import gtrnadb

from .json_to_csv import GtRNAdbJsonToCsv


class GtRNAdb(luigi.WrapperTask):  # pylint: disable=R0904
    """
    Imports all GtRNAdb data. This will generate a task for each separate file to
    create the CSV files, but does not run the secondary structure importing.
    That has to be trigger manually after this is complete.
    """

    def requires(self):
        config = gtrnadb()
        for filename in iglob(config.pattern):
            yield GtRNAdbJsonToCsv(input_file=filename)


from glob import glob

import luigi

from tasks.config import gtrnadb

from .json_to_csv import GtRNAdbJsonToCsv


class GtRNAdb(luigi.WrapperTask):  # pylint: disable=R0904
    """
    Imports all GtRNAdb data. This will generate a task for each separate file
    to create the CSV files, but does not run the secondary structure
    importing. That has to be trigger manually after this is complete.
    """

    def requires(self):
        config = gtrnadb()
        files = glob(config.pattern)
        if not files:
            raise ValueError("No GtRNAdb data files file")

        for filename in files:
            yield GtRNAdbJsonToCsv(input_file=filename)

Check that there are data files to import
Check that there are data files to import

It is possible for the pattern to match nothing leading to no files
being imported. This is an error case so we raise an exception if it
happens.

  
- from glob import iglob
+ from glob import glob
  
  import luigi
  
  from tasks.config import gtrnadb
  
  from .json_to_csv import GtRNAdbJsonToCsv
  
  
  class GtRNAdb(luigi.WrapperTask):  # pylint: disable=R0904
      """
-     Imports all GtRNAdb data. This will generate a task for each separate file to
+     Imports all GtRNAdb data. This will generate a task for each separate file
-     create the CSV files, but does not run the secondary structure importing.
+     to create the CSV files, but does not run the secondary structure
-     That has to be trigger manually after this is complete.
+     importing. That has to be trigger manually after this is complete.
      """
  
      def requires(self):
          config = gtrnadb()
-         for filename in iglob(config.pattern):
+         files = glob(config.pattern)
+         if not files:
+             raise ValueError("No GtRNAdb data files file")
+ 
+         for filename in files:
              yield GtRNAdbJsonToCsv(input_file=filename)
  
Check that there are data files to import
## Code Before:

from glob import iglob

import luigi

from tasks.config import gtrnadb

from .json_to_csv import GtRNAdbJsonToCsv


class GtRNAdb(luigi.WrapperTask):  # pylint: disable=R0904
    """
    Imports all GtRNAdb data. This will generate a task for each separate file to
    create the CSV files, but does not run the secondary structure importing.
    That has to be trigger manually after this is complete.
    """

    def requires(self):
        config = gtrnadb()
        for filename in iglob(config.pattern):
            yield GtRNAdbJsonToCsv(input_file=filename)

## Instruction:
Check that there are data files to import
## Code After:

from glob import glob

import luigi

from tasks.config import gtrnadb

from .json_to_csv import GtRNAdbJsonToCsv


class GtRNAdb(luigi.WrapperTask):  # pylint: disable=R0904
    """
    Imports all GtRNAdb data. This will generate a task for each separate file
    to create the CSV files, but does not run the secondary structure
    importing. That has to be trigger manually after this is complete.
    """

    def requires(self):
        config = gtrnadb()
        files = glob(config.pattern)
        if not files:
            raise ValueError("No GtRNAdb data files file")

        for filename in files:
            yield GtRNAdbJsonToCsv(input_file=filename)
