<commit_before># Copyright (C) 2014-2016 New York University
# This file is part of ReproZip which is released under the Revised BSD License
# See file LICENSE for full license details.

from __future__ import division, print_function, unicode_literals

import re
import yaml

from PyQt4 import QtCore, QtGui

import reprounzip_qt.reprounzip_interface as reprounzip
from reprounzip_qt.gui.common import ROOT, ResizableStack, handle_error, \
    error_msg


class RunOptions(QtGui.QWidget):
    x11 = None

    def __init__(self):
        super(RunOptions, self).__init__()
        self.setLayout(QtGui.QGridLayout())

    def add_row(self, label, widget):
        layout = self.layout()
        row = layout.rowCount()
        layout.addWidget(QtGui.QLabel(label), row, 0)
        layout.addWidget(widget, row, 1)

    def add_row_layout(self, label, rowlayout):
        layout = self.layout()
        row = layout.rowCount()
        layout.addWidget(QtGui.QLabel(label), row, 0)
        layout.addLayout(rowlayout, row, 1)

    def add_x11(self):
        self.x11 = QtGui.QCheckBox("enabled", checked=False)
        self.add_row("X11 display:", self.x11)

    def options(self):
        options = {'args': []}

        if self.x11 is not None and self.x11.isChecked():
            options['args'].append('--enable-x11')

        return options


class DirectoryOptions(RunOptions):
    def __init__(self):
        super(DirectoryOptions, self).__init__()
        self.add_x11()


class ChrootOptions(RunOptions):
    def __init__(self):
        super(ChrootOptions, self).__init__()
        self.add_x11()


class DockerOptions(RunOptions):
    _port_re = re.compile('^(?:([0-9]+):)?([0-9]+)(?:/([a-z]+))?$')

    def __init__(self):
        super(DockerOptions, self).__init__()

        self.x11 = QtGui.QCheckBox("enabled", checked=False)
        self.tunneled_x11 = QtGui.QCheckBox("use tunnel", checked=False)
        row = QtGui.QVBoxLayout()
        row.addWidget(self.x11)
        row.addWidget(self.tunneled_x11)
        row.addStretch(1)
        self.add_row_layout("X11 display:", row)

        self.detach = QtGui.QCheckBox("start background container and leave "
                                      "it running",
                                      checked=False)
        self.add_row("Detach:", self.detach)

        self.raw_options = QtGui.QLineEdit('')
        self.add_row("Raw Docker options:", self.raw_options)

        self.ports = QtGui.QLineEdit('')
        self.add_row("Publish ports:", self.ports)

    def options(self):
        options = super(DockerOptions, self).options()<commit_msg>GUI: Fix layout direction for Docker X11 options<commit_after># Copyright (C) 2014-2016 New York University
# This file is part of ReproZip which is released under the Revised BSD License
# See file LICENSE for full license details.

from __future__ import division, print_function, unicode_literals

import re
import yaml

from PyQt4 import QtCore, QtGui

import reprounzip_qt.reprounzip_interface as reprounzip
from reprounzip_qt.gui.common import ROOT, ResizableStack, handle_error, \
    error_msg


class RunOptions(QtGui.QWidget):
    x11 = None

    def __init__(self):
        super(RunOptions, self).__init__()
        self.setLayout(QtGui.QGridLayout())

    def add_row(self, label, widget):
        layout = self.layout()
        row = layout.rowCount()
        layout.addWidget(QtGui.QLabel(label), row, 0)
        layout.addWidget(widget, row, 1)

    def add_row_layout(self, label, rowlayout):
        layout = self.layout()
        row = layout.rowCount()
        layout.addWidget(QtGui.QLabel(label), row, 0)
        layout.addLayout(rowlayout, row, 1)

    def add_x11(self):
        self.x11 = QtGui.QCheckBox("enabled", checked=False)
        self.add_row("X11 display:", self.x11)

    def options(self):
        options = {'args': []}

        if self.x11 is not None and self.x11.isChecked():
            options['args'].append('--enable-x11')

        return options


class DirectoryOptions(RunOptions):
    def __init__(self):
        super(DirectoryOptions, self).__init__()
        self.add_x11()


class ChrootOptions(RunOptions):
    def __init__(self):
        super(ChrootOptions, self).__init__()
        self.add_x11()


class DockerOptions(RunOptions):
    _port_re = re.compile('^(?:([0-9]+):)?([0-9]+)(?:/([a-z]+))?$')

    def __init__(self):
        super(DockerOptions, self).__init__()

        self.x11 = QtGui.QCheckBox("enabled", checked=False)
        self.tunneled_x11 = QtGui.QCheckBox("use tunnel", checked=False)
        row = QtGui.QHBoxLayout()
        row.addWidget(self.x11)
        row.addWidget(self.tunneled_x11)
        row.addStretch(1)
        self.add_row_layout("X11 display:", row)

        self.detach = QtGui.QCheckBox("start background container and leave "
                                      "it running",
                                      checked=False)
        self.add_row("Detach:", self.detach)

        self.raw_options = QtGui.QLineEdit('')
        self.add_row("Raw Docker options:", self.raw_options)

        self.ports = QtGui.QLineEdit('')
        self.add_row("Publish ports:", self.ports)

    def options(self):
        options = super(DockerOptions, self).options()
{'fraction_non_alphanumeric': 0.12151658767772512, 'fraction_numerical': 0.0185781990521327, 'mean_word_length': 2.7793696275071635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2218593', 'n_tokens_mistral': 1736, 'n_tokens_neox': 1619, 'n_words': 360}