Generates a copyright string for the specified copyright holder from the
specified first year to the current year.
498462
public static String copyright (String holder, int startYear)
    {
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        return "&copy; " + holder + " " + startYear + "-" + year;
    }
672997
private Collection<CopyrightInfo> extractCopyrights(File file) {
        Collection<CopyrightInfo> copyrights = new ArrayList<>();
        try {
            boolean commentBlock = false;
            Iterator<String> iterator = FileUtils.readLines(file).iterator();
            int lineIndex = 1;
            while (iterator.hasNext()) {
                // trim (duh..)
                String line = iterator.next().trim();

                // check if comment block
                if (!commentBlock) {
                    for (Map.Entry<String, String> entry : commentStartEndMap.entrySet()) {
                        String commentStart = entry.getKey();
                        String commentEnd = entry.getValue();
                        if (line.startsWith(commentStart)) {
                            if (line.contains(commentEnd)) {
                                commentBlock = false;
                                int endIndex = line.indexOf(commentEnd);
                                int commentLength = commentStart.length();
                                if (endIndex >= commentLength) {
                                    line = line.substring(commentLength, endIndex);
                                } else {
                                    line = Constants.EMPTY_STRING;
                                }
                            } else {
                                commentBlock = true;
                            }
                            break;
                        } else if (line.contains(commentStart)) {
                            int startIndex = line.indexOf(commentStart);
                            if (line.contains(commentEnd)) {
                                int endIndex = line.indexOf(commentEnd);
                                if (startIndex < endIndex) {
                                    commentBlock = false;
                                    line = line.substring(startIndex, endIndex);
                                }
                            } else {
                                commentBlock = true;
                                line = line.substring(startIndex);
                            }
                            break;
                        }
                    }
                }

                // check for one-line comments
                String lowerCaseLine = line.toLowerCase();
                if ((commentBlock || line.startsWith("//") || line.startsWith(Constants.POUND))
                        && (lowerCaseLine.contains(COPYRIGHT) || lowerCaseLine.contains(COPYRIGHT_SYMBOL) || lowerCaseLine.contains(COPYRIGHT_ASCII_SYMBOL))) {
                    // ignore lines that contain (c) and math signs (+, <, etc.) near it
                    // and ignore lines that contain © and have other invalid ascii symbols
                    if ((lowerCaseLine.contains(COPYRIGHT_SYMBOL) && isMathExpression(lowerCaseLine)) ||
                            lowerCaseLine.contains(COPYRIGHT_ASCII_SYMBOL) && hasInvalidAsciiChars(lowerCaseLine)) {
                        continue;
                    }
                    line = cleanLine(line);

                    if (line.toLowerCase().matches(TODO_PATTERN)) {
                        continue;
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.append(line);

                    // check if copyright continues to next line
                    boolean continuedToNextLine = false;
                    if (iterator.hasNext()) {
                        String copyrightOwner = null;
                        lowerCaseLine = line.toLowerCase();
                        for (String copyrightText : COPYRIGHT_TEXTS) {
                            if (lowerCaseLine.startsWith(copyrightText)) {
                                copyrightOwner = line.substring(copyrightText.length()).trim();
                                break;
                            }
                        }

                        if (copyrightOwner != null) {
                            // check if copyright contains an alpha char (not just years)
                            if (!copyrightOwner.matches(COPYRIGHT_ALPHA_CHAR_REGEX)) {
                                // check if line has ending of comment block
                                for (String commentEnd : commentStartEndMap.values()) {
                                    if (line.contains(commentEnd)) {
                                        commentBlock = false;
                                        break;
                                    }
                                }

                                // if still in comment block, read next line
                                if (commentBlock) {
                                    String nextLine = cleanLine(iterator.next());
                                    sb.append(Constants.WHITESPACE);
                                    sb.append(nextLine);
                                    continuedToNextLine = true;
                                    line = nextLine;
                                }
                            }
                        }
                    }

                    // remove "all rights reserved" if exists
                    String copyright = sb.toString();
                    String lowercaseCopyright = copyright.toLowerCase();
                    if (lowercaseCopyright.contains(ALL_RIGHTS_RESERVED)) {
                        int startIndex = lowercaseCopyright.indexOf(ALL_RIGHTS_RESERVED);
                        int endIndex = startIndex + ALL_RIGHTS_RESERVED.length();
                        if (endIndex == copyright.length()) {
                            copyright = copyright.substring(0, startIndex).trim();
                        } else {
                            copyright = copyright.substring(0, startIndex).trim() + Constants.WHITESPACE + copyright.substring(endIndex).trim();
                        }
                    }
                    copyrights.add(new CopyrightInfo(copyright, lineIndex));

                    if (continuedToNextLine) {
                        lineIndex++;
                    }
                }

                // check if line has ending of comment block
                for (String commentEnd : commentStartEndMap.values()) {
                    if (line.contains(commentEnd)) {
                        commentBlock = false;
                        break;
                    }
                }
                lineIndex++;
            }
        } catch (FileNotFoundException e) {
            logger.warn("File not found: " + file.getPath());
        } catch (IOException e) {
            logger.warn("Error reading file: " + file.getPath());
        }

        removeRedundantCopyrights(copyrights);

        return copyrights;
    }
209276
def gen_str_to_sign(self, req):
        """"""
        url = urlsplit(req.url)
        bucket_name = url.netloc.split(".", 1)[0]

        logger.debug(req.headers.items())
        ucloud_headers = [
            (k, v.strip())
            for k, v in sorted(req.headers.lower_items())
            if k.startswith("x-ucloud-")
        ]
        canonicalized_headers = "\n".join([
            "{0}:{1}".format(k, v) for k, v in ucloud_headers
        ])

        canonicalized_resource = "/{0}{1}".format(
            bucket_name,
            unquote(url.path)
        )

        str_to_sign = "\n".join([
            req.method,
            req.headers.get("content-md5", ""),
            req.headers.get("content-type", ""),
            req.headers.get("date", self._expires),
            canonicalized_headers + canonicalized_resource
        ])
        return str_to_sign
104839
def generate(self):
        

        result = self._gen(self.optimized, self.splitstring)
        if self.splitstring and result is not None:
            result = result[1:]
        return result
876732
static Generator byYearGenerator(int[] years, final DateValue dtStart) {
        final int[] uyears = Util.uniquify(years);

        // index into years
        return new Generator() {
            int i;

            {
                while (i < uyears.length && dtStart.year() > uyears[i]) {
                    ++i;
                }
            }

            @Override
            boolean generate(DTBuilder builder) {
                if (i >= uyears.length) {
                    return false;
                }
                builder.year = uyears[i++];
                return true;
            }

            @Override
            public String toString() {
                return "byYearGenerator";
            }
        };
    }
1059287
def obtain_archive_year

      if get_type_by_url == 'AR'
        segments = params[:slug].split('/')
        str = ''
        str = (get_date_name_by_number(segments[2].to_i) + ' ') if !segments[2].blank?
        str += segments[1]
      end

    end
521579
def make_article_info_copyright(self, article_info_div):
        
        perm = self.article.root.xpath('./front/article-meta/permissions')
        if not perm:
            return
        copyright_div = etree.SubElement(article_info_div, 'div', {'id': 'copyright'})
        cp_bold = etree.SubElement(copyright_div, 'b')
        cp_bold.text = 'Copyright: '
        copyright_string = '\u00A9 '
        copyright_holder = perm[0].find('copyright-holder')
        if copyright_holder is not None:
            copyright_string += all_text(copyright_holder) + '. '
        lic = perm[0].find('license')
        if lic is not None:
            copyright_string += all_text(lic.find('license-p'))
        append_new_text(copyright_div, copyright_string)
1339970
def format_year(year):
    
    if isinstance(year, (date, datetime)):
        # Django 1.5 and up, 'year' is a date object, consistent with month+day views.
        return unicode(year.year)
    else:
        # Django 1.4 just passes the kwarg as string.
        return unicode(year)
1312713
def generate_license(args):
    '''
    
    '''

    with open(cwd + licenses_loc + args[2]) as f:
        license = f.read()

    license = license.format(name=args[0],
                             email=args[1],
                             license=args[2],
                             project=args[3],
                             year=args[5])

    with open('LICENSE' + args[4], 'w') as f:
        f.write(license)
        print('licenser: license file added to current directory')
464272
private boolean sameAction(String first) {
    StringBuilder firstSb = new StringBuilder(Strings.substringBefore(first, "."));
    if (-1 == firstSb.lastIndexOf("!")) {
      firstSb.append("!index");
    }
    return firstSb.toString().equals(uri);
  }
597369
public function getCopyright()
    {
        if ($this->copyright === null) {
            $match = [];
            preg_match(self::$REGEX_COPYRIGHT, $this->output, $match);
            $this->copyright = array_key_exists(2, $match) ? trim($match[2]) : '';
        }

        return $this->copyright;
    }
175123
def copyright2marc(self, key, value):
    """"""
    E_MAP = {
        'publication': 'Article',
    }

    e_value = value.get('material')

    return {
        'd': value.get('holder'),
        'e': E_MAP.get(e_value),
        'f': value.get('statement'),
        'g': value.get('year'),
        'u': value.get('url'),
    }
1310368
def merch_year_from_date(date)
      if end_of_year(date.year) >= date
        return date.year
      else
        return date.year + 1
      end
    end
338817
private static License createLicenseObject(SpdxListedLicense spdxListedLicense) {
        final License license = new License();
        license.setId(spdxListedLicense.getLicenseId());
        license.setName(spdxListedLicense.getName());
        if (spdxListedLicense.getSeeAlso() != null && spdxListedLicense.getSeeAlso().length > 0) {
            license.setUrl(spdxListedLicense.getSeeAlso()[0]);
        }
        if (spdxListedLicense.getLicenseText() != null) {
            final LicenseText text = new LicenseText();
            text.setContentType("plain/text");
            text.setEncoding("base64");
            text.setText(Base64.getEncoder().encodeToString(spdxListedLicense.getLicenseText().getBytes()));
            license.setLicenseText(text);
        }
        return license;
    }
1363832
public static Version stringToVersion(String str) {
        if (str == null || str.isEmpty() || str.equals("0")) {
            return Version.emptyVersion;
        }

        if (str.equals("1") || str.equals("1.0") || str.equals("1.0.0"))
            return VERSION_1_0;

        return new Version(str);
    }
489777
def copyright(self) -> str:  # noqa: A003
        
        return '© {}, {}'.format(
            self.company(),
            self.company_type(abbr=True),
        )
1233111
public function getCopyrightYear()
    {
        if ($this->YearStart && $this->YearFinish) {
            return sprintf('%d-%d', $this->YearStart, $this->YearFinish);
        } elseif ($this->YearStart && !$this->YearFinish) {
            return sprintf('%d-%d', $this->YearStart, date('Y'));
        } elseif (!$this->YearStart && $this->YearFinish) {
            return $this->YearFinish;
        }
        
        return (string) date('Y');
    }